Skip to content

Commit

Permalink
Also test abc.ABC compatibilities.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwgk committed Feb 5, 2024
1 parent 0d29c62 commit db53f4a
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions tests/test_methods_and_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,24 @@ def test_metaclass_override():


def test_abc_meta_incompatibility(): # Mostly to clearly expose the behavior.
with pytest.raises(TypeError) as exc_info:
with pytest.raises(TypeError, match="metaclass conflict"):

class ExampleMandAABC(m.ExampleMandA, metaclass=abc.ABCMeta):
pass

assert "metaclass conflict" in str(exc_info.value)

def test_abc_abc_1st_incompatibility(): # Mostly to clearly expose the behavior.
with pytest.raises(TypeError, match="metaclass conflict"):

class ABCExampleMandA(abc.ABC, m.ExampleMandA):
pass


def test_abc_abc_2nd_incompatibility(): # Mostly to clearly expose the behavior.
with pytest.raises(TypeError, match="metaclass conflict"):

class ExampleMandAABC(m.ExampleMandA, abc.ABC):
pass


def test_abc_meta_compatibility():
Expand All @@ -244,6 +256,20 @@ class MetaclassOverrideABC(m.MetaclassOverride, metaclass=abc.ABCMeta):
assert type(MetaclassOverrideABC).__name__ == "ABCMeta"


def test_abc_abc_1st_compatibility():
class ABCMetaclassOverride(abc.ABC, m.MetaclassOverride):
pass

assert type(ABCMetaclassOverride).__name__ == "ABCMeta"


def test_abc_abc_2nd_compatibility():
class MetaclassOverrideABC(m.MetaclassOverride, abc.ABC):
pass

assert type(MetaclassOverrideABC).__name__ == "ABCMeta"


def test_no_mixed_overloads():
from pybind11_tests import detailed_error_messages_enabled

Expand Down

0 comments on commit db53f4a

Please sign in to comment.