コード例 #1
0
    def test_should_register_negated_matcher(self):
        @register_matcher(self.name, negated=True)
        class SomeMatcher(Matcher): pass

        matcher = MatcherRegistry.instance().resolve_matchers(self.name)[0]()

        self.assertTrue(isinstance(matcher, NegatedMatcherDecorator))
コード例 #2
0
    def test_should_register_negated_matcher(self):
        @register_matcher(self.name, negated=True)
        class SomeMatcher(Matcher):
            pass

        matcher = MatcherRegistry.instance().resolve_matchers(self.name)[0]()

        self.assertTrue(isinstance(matcher, NegatedMatcherDecorator))
コード例 #3
0
    def test_should_register_matcher(self):
        @register_matcher(self.name)
        class SomeMatcher(Matcher):
            pass

        self.assertEquals([SomeMatcher],
                          MatcherRegistry.instance().resolve_matchers(
                              self.name))
コード例 #4
0
    def test_should_register_matcher(self):
        @register_matcher(self.name)
        class SomeMatcher(Matcher): pass

        self.assertEquals([SomeMatcher], MatcherRegistry.instance().resolve_matchers(self.name))
コード例 #5
0
 def setUp(self):
     unittest.TestCase.setUp(self)
     self.registry = MatcherRegistry()
コード例 #6
0
class MatcherRegistryTest(unittest.TestCase):
    def setUp(self):
        unittest.TestCase.setUp(self)
        self.registry = MatcherRegistry()

    def test_should_register_and_resolve_single_matcher(self):
        self.registry.register_matcher("spam", AnyMatcher)
        self.assertEquals([AnyMatcher], self.registry.resolve_matchers("spam"))

    def test_should_register_two_matcher_and_resolve_single_matcher(self):
        self.registry.register_matcher("spam", AnyMatcher)
        self.registry.register_matcher("eggs", AnyOtherMatcher)
        self.assertEquals([AnyMatcher], self.registry.resolve_matchers("spam"))

    def test_should_register_two_matcher_on_the_same_name_and_resolve_two_matcher(self):
        self.registry.register_matcher("spam", AnyMatcher)
        self.registry.register_matcher("spam", AnyOtherMatcher)
        self.assertEquals([AnyMatcher, AnyOtherMatcher],
            self.registry.resolve_matchers("spam"))
コード例 #7
0
 def setUp(self):
     unittest.TestCase.setUp(self)
     self.registry = MatcherRegistry()
コード例 #8
0
class MatcherRegistryTest(unittest.TestCase):
    def setUp(self):
        unittest.TestCase.setUp(self)
        self.registry = MatcherRegistry()

    def test_should_register_and_resolve_single_matcher(self):
        self.registry.register_matcher("spam", AnyMatcher)
        self.assertEquals([AnyMatcher], self.registry.resolve_matchers("spam"))

    def test_should_register_two_matcher_and_resolve_single_matcher(self):
        self.registry.register_matcher("spam", AnyMatcher)
        self.registry.register_matcher("eggs", AnyOtherMatcher)
        self.assertEquals([AnyMatcher], self.registry.resolve_matchers("spam"))

    def test_should_register_two_matcher_on_the_same_name_and_resolve_two_matcher(
            self):
        self.registry.register_matcher("spam", AnyMatcher)
        self.registry.register_matcher("spam", AnyOtherMatcher)
        self.assertEquals([AnyMatcher, AnyOtherMatcher],
                          self.registry.resolve_matchers("spam"))