Пример #1
0
 def test_value_from_parsed_string(self):
     t = token.Token("name", "[a-z]+", "s")
     assert t.value_from_parsed_string("abc") == "abc"
Пример #2
0
    def test_parse(self):
        t = token.Token("name", "[a-zA-Z]+", "")
        assert t.parse("abc") == "abc"

        with pytest.raises(exceptions.ParseError):
            t.parse("ab2")
Пример #3
0
 def test_regex(self):
     t = token.Token("name", "[a-zA-Z]+", "")
     assert t.regex() == "[a-zA-Z]+"
Пример #4
0
 def test_format_spec(self):
     t = token.Token("name", "[a-z]", "")
     assert t.format_spec == ""
Пример #5
0
    def test_format(self):
        t = token.Token("name", "[a-zA-Z]+", "")
        assert t.format("abc") == "abc"

        with pytest.raises(exceptions.FormatError):
            t.format("123")
Пример #6
0
 def test_name(self):
     t = token.Token("name", "", "")
     assert t.name == "name"
Пример #7
0
 def test_str(self):
     t = token.Token("name", "[a-zA-Z]+", "")
     assert str(t) == "name"
Пример #8
0
 def test_repr(self):
     t = token.Token("name", "[a-zA-Z]+", "")
     assert repr(
         t
     ) == "Token('name', '[a-zA-Z]+', '', description='', default=None)"