def test_bad_input_order(self): u = Untokenizer() u.prev_row = 2 u.prev_col = 2 with self.assertRaises(ValueError) as cm: u.add_whitespace((1,3)) self.assertEqual(cm.exception.args[0], 'start (1,3) precedes previous end (2,2)') self.assertRaises(ValueError, u.add_whitespace, (2,1))
def test_backslash_continuation(self): # The problem is that <whitespace>\<newline> leaves no token u = Untokenizer() u.prev_row = 1 u.prev_col = 1 u.tokens = [] u.add_whitespace((2, 0)) self.assertEqual(u.tokens, ['\\\n']) u.prev_row = 2 u.add_whitespace((4, 4)) self.assertEqual(u.tokens, ['\\\n', '\\\n\\\n', ' '])
def test_bad_input_order(self): # raise if previous row u = Untokenizer() u.prev_row = 2 u.prev_col = 2 with self.assertRaises(ValueError) as cm: u.add_whitespace((1, 3)) self.assertEqual(cm.exception.args[0], 'start (1,3) precedes previous end (2,2)') # raise if previous column in row self.assertRaises(ValueError, u.add_whitespace, (2, 1))