Skip to content

Commit

Permalink
Test for classes with no constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
wlav committed Feb 26, 2022
1 parent 981a9e8 commit 40d3536
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ master: 2.3.0
* Fix regression for accessing `char16_t` data member arrays
* Add custom `__reshape__` method to CPPInstance to allow array cast
* Prioritize callee exceptions over bindings exceptions
* Prevent infinite recursion when instantiating class with no constructors


2021-11-14: 2.2.0
Expand Down
43 changes: 43 additions & 0 deletions test/test_crossinheritance.py
Original file line number Diff line number Diff line change
Expand Up @@ -1562,3 +1562,46 @@ def func(self):

c = C()
assert c.func() == 3

def test34_no_ctors_in_base(self):
"""Base classes with no constructors"""

import cppyy

cppyy.cppdef("""\
namespace BlockedCtors {
class Z {
public:
virtual ~Z() {}
};
class X : Z {
X();
X(const X&&) = delete;
};
class Y: Z {
protected:
Y() {}
Y(const Y&&) = delete;
}; }""")

ns = cppyy.gbl.BlockedCtors

with raises(TypeError):
ns.X()

with raises(TypeError):
ns.Y()

class PyY1(ns.Y):
pass

with raises(TypeError):
PyY1()

class PyY2(ns.Y):
def __init__(self):
super(ns.Y, self).__init__()

assert PyY2()

0 comments on commit 40d3536

Please sign in to comment.