Exemple #1
0
 def setUp(self):
     class SomeClass(object):
         pass
     self.some_binding_key = binding_keys.new('some_class')
     self.some_binding = new_in_default_scope(
         self.some_binding_key,
         bindings_lib.create_instance_proviser_fn(
             self.some_binding_key, 'unused'))
     self.another_some_binding = new_in_default_scope(
         self.some_binding_key,
         bindings_lib.create_instance_proviser_fn(
             self.some_binding_key, 'also-unused'))
Exemple #2
0
 def test_colliding_bindings_raises_error(self):
     binding_key = binding_keys.new('unused')
     binding_one = new_in_default_scope(
         binding_key,
         bindings_lib.create_instance_proviser_fn(binding_key, 'unused'))
     binding_two = new_in_default_scope(
         binding_key,
         bindings_lib.create_instance_proviser_fn(binding_key, 'unused'))
     binding_mapping = bindings_lib.BindingMapping(
         {}, {'colliding-binding-key': [binding_one, binding_two]})
     self.assertRaises(errors.AmbiguousArgNameError,
                       binding_mapping.get, 'colliding-binding-key')
def new_test_obj_provider(arg_binding_key, instance, allow_injecting_none=True):
    binding_key = arg_binding_key.binding_key
    binding = bindings.Binding(
        binding_key,
        bindings.create_instance_proviser_fn(binding_key, instance),
        'a-scope', 'unused-desc')
    binding_mapping = bindings.BindingMapping({binding_key: binding}, {})
    bindable_scopes = scoping.BindableScopes(
        {'a-scope': scoping.PrototypeScope()})
    return object_providers.ObjectProvider(
        binding_mapping, bindable_scopes, allow_injecting_none)
 def setUp(self):
     self.binding_key = binding_keys.new('foo')
     self.binding = bindings.Binding(
         self.binding_key,
         bindings.create_instance_proviser_fn(
             self.binding_key, 'an-instance'),
         'curr-scope', 'unused-desc')
     injection_context_factory = injection_contexts.InjectionContextFactory(
         lambda to_scope, from_scope: to_scope != 'unusable-scope')
     top_injection_context = injection_context_factory.new()
     self.injection_context = top_injection_context.get_child(self.binding)