# Path: snakeguice/injector.py
# def create_injector(modules):
#     """Factory for creating Injector instances."""
#     return Injector(modules)
# 
# Path: snakeguice/decorators.py
# def inject(**kwargs):
# 
#     scope = kwargs.get('scope')
#     if 'scope' in kwargs:
#         del kwargs['scope']
# 
#     def _inject(func):
#         class_locals = enclosing_frame().f_locals
# 
#         guice_data = GuiceData.from_class_dict(class_locals)
# 
#         annotations = getattr(func, '__guice_annotations__', {})
# 
#         gmethod = dict((k, GuiceArg(v, annotations.get(k)))
#                        for k, v in kwargs.items())
# 
#         _validate_func_args(func, kwargs)
#         if func.__name__ == '__init__':
#             guice_data.init = gmethod
#         else:
#             guice_data.methods[func.__name__] = gmethod
# 
#         return func
# 
#     return _inject
# 
# class annotate(object):
# 
#     def __init__(self, **kwargs):
#         self.kwargs = kwargs
# 
#     def __call__(self, method):
#         class_locals = enclosing_frame().f_locals
#         if '__guice__' in class_locals:
#             if method.__name__ in class_locals['__guice__'].methods:
#                 raise Exception('annotate must be applied before inject')
#         method.__guice_annotations__ = self.kwargs
#         return method
# 
# Path: snakeguice/assist.py
# def assisted_inject(**kwargs):
#     def _assisted_inject(func):
# def AssistProvider(cls):
#         def __init__(self, injector):
#         def get(self):
# def build_factory(injector, cls):
#         def create(self, **kwargs):
#     class _AssistProvider(object):
#     class DynamicFactory(object):


from nose.tools import raises
from snakeguice import inject, create_injector, annotate
from snakeguice.assist import assisted_inject, assisted, AssistProvider
from snakeguice.errors import AssistError
class Module(object):

    def configure(self, binder):
        binder.bind(IWorkerFactory, to_provider=AssistProvider(Worker))
        binder.bind(IService, annotated_with="customer", to=CustomerService)
        binder.bind(IService, annotated_with="order", to=OrderService)


class test_partiall_injecting_an_object(object):

    def setup(self):
        inj = create_injector([Module()])
        self.manager = inj.get_instance(Manager)

    def test(self):
        assert isinstance(self.manager.worker, Worker)


class base_AssistProvider_decorator_errors(object):

    @raises(AssistError)
    def test_that_an_exception_is_raised(self):
        AssistProvider(self.C)


class test_creating_an_AssistProvider_from_an_inject(
        base_AssistProvider_decorator_errors):

    def setup(self):
        class C(object):

# Path: snakeguice/injector.py
# def create_injector(modules):
#     """Factory for creating Injector instances."""
#     return Injector(modules)
# 
# Path: snakeguice/decorators.py
# def inject(**kwargs):
# 
#     scope = kwargs.get('scope')
#     if 'scope' in kwargs:
#         del kwargs['scope']
# 
#     def _inject(func):
#         class_locals = enclosing_frame().f_locals
# 
#         guice_data = GuiceData.from_class_dict(class_locals)
# 
#         annotations = getattr(func, '__guice_annotations__', {})
# 
#         gmethod = dict((k, GuiceArg(v, annotations.get(k)))
#                        for k, v in kwargs.items())
# 
#         _validate_func_args(func, kwargs)
#         if func.__name__ == '__init__':
#             guice_data.init = gmethod
#         else:
#             guice_data.methods[func.__name__] = gmethod
# 
#         return func
# 
#     return _inject
# 
# class annotate(object):
# 
#     def __init__(self, **kwargs):
#         self.kwargs = kwargs
# 
#     def __call__(self, method):
#         class_locals = enclosing_frame().f_locals
#         if '__guice__' in class_locals:
#             if method.__name__ in class_locals['__guice__'].methods:
#                 raise Exception('annotate must be applied before inject')
#         method.__guice_annotations__ = self.kwargs
#         return method
# 
# Path: snakeguice/assist.py
# def assisted_inject(**kwargs):
#     def _assisted_inject(func):
# def AssistProvider(cls):
#         def __init__(self, injector):
#         def get(self):
# def build_factory(injector, cls):
#         def create(self, **kwargs):
#     class _AssistProvider(object):
#     class DynamicFactory(object):


# Path: tests/test_assist.py
from nose.tools import raises
from snakeguice import inject, create_injector, annotate
from snakeguice.assist import assisted_inject, assisted, AssistProvider
from snakeguice.errors import AssistError

class Module(object):

    def configure(self, binder):
        binder.bind(IWorkerFactory, to_provider=AssistProvider(Worker))
        binder.bind(IService, annotated_with="customer", to=CustomerService)
        binder.bind(IService, annotated_with="order", to=OrderService)


class test_partiall_injecting_an_object(object):

    def setup(self):
        inj = create_injector([Module()])
        self.manager = inj.get_instance(Manager)

    def test(self):
        assert isinstance(self.manager.worker, Worker)


class base_AssistProvider_decorator_errors(object):

    @raises(AssistError)
    def test_that_an_exception_is_raised(self):
        AssistProvider(self.C)


class test_creating_an_AssistProvider_from_an_inject(
        base_AssistProvider_decorator_errors):

    def setup(self):
        class C(object):

            @inject(x=object)