<commit_before>#!/usr/bin/env python

"""
Examples of using the snakeguice API.
"""

#TODO: add a test proving call throughs work


from snakeguice import inject, Injected, ParameterInterceptor, annotate
from snakeguice import Injector, provides

import cls_heirarchy as ch


class given_an_injector(object):

    def when_asking_for_a_class_not_bound_by_a_module(self):
        injector = Injector([])
        self.person = injector.get_instance(ch.Person)

    def then_an_instance_of_it_is_implicitly_bound(self):
        assert isinstance(self.person, ch.Person)


def test_injector_simple():
    class MyModule:
        def configure(self, binder):
            binder.bind(ch.Person, to=ch.EvilPerson)

    injector = Injector(MyModule())
    person = injector.get_instance(ch.Person)
    assert isinstance(person, ch.EvilPerson)


def test_annotated_injector():
    class DomainObject(object):
        @inject(person0=ch.Person, person1=ch.Person, person2=ch.Person)
        @annotate(person0='good', person1='evil')<commit_msg>updated test to reflect the new import structure<commit_after>#!/usr/bin/env python

"""
Examples of using the snakeguice API.
"""

#TODO: add a test proving call throughs work


from snakeguice import inject, Injected, ParameterInterceptor, annotate
from snakeguice import Injector, provides

from .. import cls_heirarchy as ch


class given_an_injector(object):

    def when_asking_for_a_class_not_bound_by_a_module(self):
        injector = Injector([])
        self.person = injector.get_instance(ch.Person)

    def then_an_instance_of_it_is_implicitly_bound(self):
        assert isinstance(self.person, ch.Person)


def test_injector_simple():
    class MyModule:
        def configure(self, binder):
            binder.bind(ch.Person, to=ch.EvilPerson)

    injector = Injector(MyModule())
    person = injector.get_instance(ch.Person)
    assert isinstance(person, ch.EvilPerson)


def test_annotated_injector():
    class DomainObject(object):
        @inject(person0=ch.Person, person1=ch.Person, person2=ch.Person)
        @annotate(person0='good', person1='evil')
{'fraction_non_alphanumeric': 0.09758408337280909, 'fraction_numerical': 0.0047370914258645196, 'mean_word_length': 4.253731343283582, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4478826', 'n_tokens_mistral': 700, 'n_tokens_neox': 671, 'n_words': 147}