Add is_final to disallow inheritance from Python

- Not currently supported on PyPy
This commit is contained in:
Dustin Spicuzza
2020-04-05 02:34:00 -04:00
committed by Wenzel Jakob
parent b14aeb7cfa
commit 0dfffcf257
5 changed files with 67 additions and 2 deletions

View File

@@ -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")