Пример #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')