示例#1
0
 def test_build_itself_with_same_amount_of_regexes(self):
     rx = regex.Linker([('a', 'some reason'), ('b', 'other reason')], True)
     assert len(rx) == 2
示例#2
0
 def test_do_not_accept_non_pairs(self):
     with raises(TypeError):
         regex.Linker([('a', )], True)
示例#3
0
 def test_fail_on_first_regex_with_prepending(self):
     rx = regex.Linker(self.rxs, True)
     with raises(AssertionError) as exc:
         rx(' ')
     error = exc.value.args[0]
     assert error == 'does not begin with a word'
示例#4
0
 def test_fail_on_last_regex(self):
     rx = regex.Linker(self.rxs)
     with raises(AssertionError) as exc:
         rx('d- ')
     error = exc.value.args[0]
     assert error == 'end with an underscore'
示例#5
0
 def test_fail_on_second_regex(self):
     rx = regex.Linker(self.rxs)
     with raises(AssertionError) as exc:
         rx('f ')
     error = exc.value.args[0]
     assert error == 'follow a dash'
示例#6
0
 def test_fail_on_first_regex(self):
     rx = regex.Linker(self.rxs)
     with raises(AssertionError) as exc:
         rx(' ')
     error = exc.value.args[0]
     assert error == 'begin with a word'
示例#7
0
 def test_assertion_error_has_message(self):
     rx = regex.Linker([(r"\w+$", "does not begin with a word")])
     with raises(AssertionError) as exc:
         rx('_*')
     error = exc.value.args[0]
     assert error == 'does not begin with a word'
示例#8
0
 def test_assertion_error_for_failure(self):
     rx = regex.Linker([(r"\d+", "not a digit")])
     with raises(AssertionError):
         rx('f')