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))
def test_should_register_matcher(self): @register_matcher(self.name) class SomeMatcher(Matcher): pass self.assertEquals([SomeMatcher], MatcherRegistry.instance().resolve_matchers( self.name))
def test_should_register_matcher(self): @register_matcher(self.name) class SomeMatcher(Matcher): pass self.assertEquals([SomeMatcher], MatcherRegistry.instance().resolve_matchers(self.name))
def setUp(self): unittest.TestCase.setUp(self) self.registry = MatcherRegistry()
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"))
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"))