def test_Scope_len_registered(): scope = Scope() with scope.registered(str): assert len(scope) == 1 assert scope.supports(str) assert not scope.supports(str) assert len(scope) == 0
def test_Scope_registered(include_subclasses): scope = Scope() supported = [BaseA, DerBaseA, DerDerBaseA] if include_subclasses: included = [cls.__name__ for cls in supported] else: included = [BaseA.__name__] excluded = [cls.__name__ for cls in supported if not cls.__name__ in included] for cls in supported: assert not scope.supports(cls) for name in included + excluded: assert name not in scope with scope.registered(BaseA, subclasses=include_subclasses): for cls in supported: assert scope.supports(cls) for name in included: assert name in scope for name in excluded: assert name not in scope for cls in supported: assert not scope.supports(cls) for name in included + excluded: assert name not in scope
def test_Scope_len_registered_with_name(): scope = Scope() with scope.registered(string=str): assert len(scope) == 1 assert str.__name__ not in scope assert "string" in scope assert scope["string"] == str assert len(scope) == 0