import pytest | |
from ding.utils.registry import Registry | |
def test_registry(): | |
TEST_REGISTRY = Registry() | |
class A: | |
pass | |
instance = TEST_REGISTRY.build('a') | |
assert isinstance(instance, A) | |
with pytest.raises(AssertionError): | |
class A1: | |
pass | |
class A2: | |
pass | |
instance = TEST_REGISTRY.build('a') | |
assert isinstance(instance, A2) | |