mirror of
https://github.com/pybind/pybind11.git
synced 2026-03-14 20:27:47 +00:00
Add is_final to disallow inheritance from Python
- Not currently supported on PyPy
This commit is contained in:
committed by
Wenzel Jakob
parent
b14aeb7cfa
commit
0dfffcf257
@@ -279,3 +279,21 @@ def test_aligned():
|
||||
if hasattr(m, "Aligned"):
|
||||
p = m.Aligned().ptr()
|
||||
assert p % 1024 == 0
|
||||
|
||||
|
||||
# https://bitbucket.org/pypy/pypy/issues/2742
|
||||
@pytest.unsupported_on_pypy
|
||||
def test_final():
|
||||
with pytest.raises(TypeError) as exc_info:
|
||||
class PyFinalChild(m.IsFinal):
|
||||
pass
|
||||
assert str(exc_info.value).endswith("is not an acceptable base type")
|
||||
|
||||
|
||||
# https://bitbucket.org/pypy/pypy/issues/2742
|
||||
@pytest.unsupported_on_pypy
|
||||
def test_non_final_final():
|
||||
with pytest.raises(TypeError) as exc_info:
|
||||
class PyNonFinalFinalChild(m.IsNonFinalFinal):
|
||||
pass
|
||||
assert str(exc_info.value).endswith("is not an acceptable base type")
|
||||
|
||||
Reference in New Issue
Block a user