示例#1
0
 def test_substr_from_consumed_string(self):
     s = TextScanner("abcdef")
     s.consume(2)
     assert s.substr(2) == ""
     assert s.substr(3) == "c"
     assert s.substr(4) == "cd"
     assert s.substr(10) == "cdef"
示例#2
0
 def test_substr_index_error(self):
     with pytest.raises(IndexError):
         TextScanner("").substr(-1)
     s = TextScanner("abcd")
     s.consume(2)
     with pytest.raises(IndexError):
         s.substr(1)