Add UnescapeAndSplit unittest for multi-escapes
authorIustin Pop <iustin@google.com>
Wed, 30 Nov 2011 09:33:52 +0000 (10:33 +0100)
committerMichael Hanselmann <hansmi@google.com>
Thu, 19 Jan 2012 12:42:19 +0000 (13:42 +0100)
This would have caught the bug in the first place. Argh,
hand-generated test cases!

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

test/ganeti.utils.text_unittest.py

index 91039e1..03c8d64 100755 (executable)
@@ -387,6 +387,12 @@ class TestUnescapeAndSplit(unittest.TestCase):
       b = [sep, sep, "c", "d.moo\\"]
       self.assertEqual(utils.UnescapeAndSplit("%s\\" % sep.join(a), sep=sep), b)
 
+  def testMultipleEscapes(self):
+    for sep in self._seps:
+      a = ["a", "b\\" + sep + "c", "d\\" + sep + "e\\" + sep + "f", "g"]
+      b = ["a", "b" + sep + "c", "d" + sep + "e" + sep + "f", "g"]
+      self.failUnlessEqual(utils.UnescapeAndSplit(sep.join(a), sep=sep), b)
+
 
 class TestCommaJoin(unittest.TestCase):
   def test(self):