From ee74b220c60c2b41a40e81d17237188ab3d08717 Mon Sep 17 00:00:00 2001 From: Brian Pugh Date: Tue, 11 Apr 2023 19:41:01 -0700 Subject: [PATCH] Added extended registry meta test --- tests/test_meta_extension.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/test_meta_extension.py diff --git a/tests/test_meta_extension.py b/tests/test_meta_extension.py new file mode 100644 index 0000000..c8e6e25 --- /dev/null +++ b/tests/test_meta_extension.py @@ -0,0 +1,26 @@ +from autoregistry import RegistryMeta + + +class ExtendedRegistryMeta(RegistryMeta): + def __call__(cls, *args, **kwargs): # noqa: N805 + out = super().__call__(*args, **kwargs) + out.extended_attribute = cls.__name__ + return out + + +class Foo(metaclass=ExtendedRegistryMeta): + pass + + +class Bar(Foo): + pass + + +def test_extended_registry(): + foo = Foo() + bar = Bar() + + assert foo.extended_attribute == "Foo" + assert bar.extended_attribute == "Bar" + + assert list(Foo) == ["bar"]