Exemplo n.º 1
0
 def test_basic(self):
     """Tests that a list of strings changes '[' into nested lists"""
     to_test = [
         'foo', '[', 'bar', 'a', 'b', ']', '[', 'baz', 'c', ']', '-o', 'z'
     ]
     expected = ['foo', ['bar', 'a', 'b'], ['baz', 'c'], '-o', 'z']
     result = unbracket(to_test)
     self.assertEqual(result, expected)
Exemplo n.º 2
0
 def test_basic(self):
     """Tests that a list of strings changes '[' into nested lists"""
     to_test = [
         "foo", "[", "bar", "a", "b", "]", "[", "baz", "c", "]", "-o", "z"
     ]
     expected = ["foo", ["bar", "a", "b"], ["baz", "c"], "-o", "z"]
     result = unbracket(to_test)
     self.assertEqual(result, expected)
Exemplo n.º 3
0
 def test_mismatched_close_brackets(self):
     """Tests if there isn't a corresponding '[' it raises an error"""
     msg = 'Mismatched bracket at position'
     with self.assertRaisesRegex(ValueError, msg):
         unbracket(['foo', ']', 'bar'])
Exemplo n.º 4
0
 def test_mismatched_close_brackets(self):
     """Tests if there isn't a corresponding '[' it raises an error"""
     msg = "Mismatched bracket at position"
     with self.assertRaisesRegex(ValueError, msg):
         unbracket(["foo", "]", "bar"])