def test_add_lazy_property_conflicting_resource(self, app_context: ApplicationContext): app_context.add_lazy_property(ContextScope.application, 'a', lambda ctx: 2) exc = pytest.raises(ResourceConflict, app_context.resources.add, 2, context_var='a') assert str(exc.value) == ( "Resource(types=('int',), alias='default', value=2, context_var='a') " "conflicts with an application scoped lazy property") with pytest.raises(ResourceNotFoundError): yield from app_context.resources.request(int, timeout=0)
def test_lazy_property_duplicate(self, app_context: ApplicationContext): app_context.add_lazy_property(ContextScope.application, 'foo', lambda ctx: None) exc = pytest.raises(ValueError, app_context.add_lazy_property, ContextScope.application, 'foo', lambda ctx: None) assert (str(exc.value) == 'there is already a lazy property for "foo" on the application scope')