Exemple #1
0
 def test_len(self):
     assert_equal(len(MultiMatcher()), 0)
     assert_equal(len(MultiMatcher([])), 0)
     assert_equal(len(MultiMatcher(['one', 'two'])), 2)
     assert_equal(len(MultiMatcher(regexp=True)), 0)
     assert_equal(len(MultiMatcher([], regexp=True)), 0)
     assert_equal(len(MultiMatcher(['one', 'two'], regexp=True)), 2)
 def test_match_pattern(self):
     matcher = MultiMatcher(['xxx', 'f*'], ignore='.:')
     assert matcher.match('xxx')
     assert matcher.match('foo')
     assert matcher.match('..::FOO::..')
     assert not matcher.match('bar')
 def test_regexp_match_any(self):
     matcher = MultiMatcher(['H.llo', 'w.*'], regexp=True)
     assert matcher.match_any(('Hi', 'world'))
     assert matcher.match_any(['jam', 'is', 'hillo'])
     assert not matcher.match_any(('no', 'match', 'here'))
     assert not matcher.match_any(())
 def test_match_any(self):
     matcher = MultiMatcher(['H?llo', 'w*'])
     assert matcher.match_any(('Hi', 'world'))
     assert matcher.match_any(['jam', 'is', 'hillo'])
     assert not matcher.match_any(('no', 'match', 'here'))
     assert not matcher.match_any(())
 def test_regexp_single_string_is_converted_to_list(self):
     matcher = MultiMatcher('one string', regexp=True)
     assert matcher.match('one string')
     assert not matcher.match('o')
     assert_equal(len(matcher), 1)
 def test_match_regexp_pattern(self):
     matcher = MultiMatcher(['xxx', 'f.*'], ignore='_:', regexp=True)
     assert matcher.match('xxx')
     assert matcher.match('foo')
     assert matcher.match('__::FOO::__')
     assert not matcher.match('bar')
 def test_match_any(self):
     matcher = MultiMatcher(['H?llo', 'w*'])
     assert matcher.match_any(('Hi', 'world'))
     assert matcher.match_any(['jam', 'is', 'hillo'])
     assert not matcher.match_any(('no', 'match', 'here'))
     assert not matcher.match_any(())
 def test_single_string_is_converted_to_list(self):
     matcher = MultiMatcher('one string')
     assert matcher.match('one string')
     assert not matcher.match('o')
     assert_equals(len(matcher), 1)
 def test_iter(self):
     assert_equals(tuple(MultiMatcher()), ())
     assert_equals(list(MultiMatcher(['1', 'xxx', '3'])), ['1', 'xxx', '3'])
 def test_len(self):
     assert_equals(len(MultiMatcher()), 0)
     assert_equals(len(MultiMatcher([])), 0)
     assert_equals(len(MultiMatcher(['one', 'two'])), 2)
 def test_configure_to_match_when_no_patterns(self):
     assert MultiMatcher(match_if_no_patterns=True).match('xxx')
 def test_do_not_match_when_no_patterns_by_default(self):
     assert not MultiMatcher().match('xxx')
 def test_match_pattern(self):
     matcher = MultiMatcher(['xxx', 'f*'], ignore='.:')
     assert matcher.match('xxx')
     assert matcher.match('foo')
     assert matcher.match('..::FOO::..')
     assert not matcher.match('bar')
Exemple #14
0
 def test_regexp_match_any(self):
     matcher = MultiMatcher(['H.llo', 'w.*'], regexp=True)
     assert matcher.match_any(('Hi', 'world'))
     assert matcher.match_any(['jam', 'is', 'hillo'])
     assert not matcher.match_any(('no', 'match', 'here'))
     assert not matcher.match_any(())
Exemple #15
0
 def test_iter(self):
     assert_equal(tuple(MultiMatcher()), ())
     assert_equal(list(MultiMatcher(['1', 'xxx', '3'])), ['1', 'xxx', '3'])
     assert_equal(tuple(MultiMatcher(regexp=True)), ())
     assert_equal(list(MultiMatcher(['1', 'xxx', '3'], regexp=True)),
                  ['1', 'xxx', '3'])
Exemple #16
0
 def test_match_regexp_pattern(self):
     matcher = MultiMatcher(['xxx', 'f.*'], ignore='_:', regexp=True)
     assert matcher.match('xxx')
     assert matcher.match('foo')
     assert matcher.match('__::FOO::__')
     assert not matcher.match('bar')