Ejemplo n.º 1
0
    def _assisted_inject(func):
        if func.__name__ != '__init__':
            raise AssistError('assisted_inject can only be used on __init__s')

        class_locals = enclosing_frame().f_locals

        guice_data = GuiceData.from_class_dict(class_locals)
        guice_data.assisted = True  # TODO: I don't like this, but it works for now

        annotations = getattr(func, '__guice_annotations__', {})

        guice_data.init = dict(
            (k, GuiceArg(v, annotations.get(k))) for k, v in kwargs.items())

        return func
Ejemplo n.º 2
0
    def _assisted_inject(func):
        if func.__name__ != '__init__':
            raise AssistError('assisted_inject can only be used on __init__s')

        class_locals = enclosing_frame().f_locals

        guice_data = GuiceData.from_class_dict(class_locals)
        guice_data.assisted = True # TODO: I don't like this, but it works for now

        annotations = getattr(func, '__guice_annotations__', {})

        guice_data.init = dict((k, GuiceArg(v, annotations.get(k)))
                                for k, v in kwargs.items())

        return func
Ejemplo n.º 3
0
def describe_getting_GuiceData_from_a_dict():
    d = dict(__guice__=object())
    data = GuiceData.from_class_dict(d)

    def should_get_the_same_instance():
        assert d['__guice__'] is data
Ejemplo n.º 4
0
def describe_initializing_GuiceData_from_a_dict():
    d = dict()
    data = GuiceData.from_class_dict(d)

    def should_have_a_GuiceData_instance_in_dict():
        assert isinstance(d['__guice__'], GuiceData)