Exemplo n.º 1
0
 def test__bool__(self):
     assert not Lnk(None)
     assert not Lnk.charspan(-1, -1)
     assert Lnk.charspan(0, 0)
     assert Lnk.chartspan(0, 0)
     assert Lnk.tokens([])
     assert Lnk.edge(0)
Exemplo n.º 2
0
 def testTokensLnk(self):
     lnk = Lnk.tokens([1, 2, 3])
     assert lnk.type == Lnk.TOKENS
     assert lnk.data == (1, 2, 3)
     assert str(lnk) == '<1 2 3>'
     repr(lnk)  # no error
     lnk = Lnk.tokens(['1'])
     assert lnk.data == (1, )
     # empty tokens list might be invalid, but accept for now
     lnk = Lnk.tokens([])
     assert lnk.data == tuple()
     with pytest.raises(TypeError):
         Lnk.tokens(1)
     with pytest.raises(ValueError):
         Lnk.tokens(['a', 'b'])