Revision 5b69bc7c test/ganeti.utils_unittest.py
b/test/ganeti.utils_unittest.py | ||
---|---|---|
45 | 45 |
ParseUnit, AddAuthorizedKey, RemoveAuthorizedKey, \ |
46 | 46 |
ShellQuote, ShellQuoteArgs, TcpPing, ListVisibleFiles, \ |
47 | 47 |
SetEtcHostsEntry, RemoveEtcHostsEntry, FirstFree, OwnIpAddress, \ |
48 |
TailFile, ForceDictType, SafeEncode, IsNormAbsPath, FormatTime |
|
48 |
TailFile, ForceDictType, SafeEncode, IsNormAbsPath, FormatTime, \ |
|
49 |
UnescapeAndSplit |
|
49 | 50 |
|
50 | 51 |
from ganeti.errors import LockError, UnitParseError, GenericError, \ |
51 | 52 |
ProgrammerError |
... | ... | |
1053 | 1054 |
FormatTime(int(time.time())) |
1054 | 1055 |
|
1055 | 1056 |
|
1057 |
class TestUnescapeAndSplit(unittest.TestCase): |
|
1058 |
"""Testing case for UnescapeAndSplit""" |
|
1059 |
|
|
1060 |
def setUp(self): |
|
1061 |
# testing more that one separator for regexp safety |
|
1062 |
self._seps = [",", "+", "."] |
|
1063 |
|
|
1064 |
def testSimple(self): |
|
1065 |
a = ["a", "b", "c", "d"] |
|
1066 |
for sep in self._seps: |
|
1067 |
self.failUnlessEqual(UnescapeAndSplit(sep.join(a), sep=sep), a) |
|
1068 |
|
|
1069 |
def testEscape(self): |
|
1070 |
for sep in self._seps: |
|
1071 |
a = ["a", "b\\" + sep + "c", "d"] |
|
1072 |
b = ["a", "b" + sep + "c", "d"] |
|
1073 |
self.failUnlessEqual(UnescapeAndSplit(sep.join(a), sep=sep), b) |
|
1074 |
|
|
1075 |
def testDoubleEscape(self): |
|
1076 |
for sep in self._seps: |
|
1077 |
a = ["a", "b\\\\", "c", "d"] |
|
1078 |
b = ["a", "b\\", "c", "d"] |
|
1079 |
self.failUnlessEqual(UnescapeAndSplit(sep.join(a), sep=sep), b) |
|
1080 |
|
|
1081 |
def testThreeEscape(self): |
|
1082 |
for sep in self._seps: |
|
1083 |
a = ["a", "b\\\\\\" + sep + "c", "d"] |
|
1084 |
b = ["a", "b\\" + sep + "c", "d"] |
|
1085 |
self.failUnlessEqual(UnescapeAndSplit(sep.join(a), sep=sep), b) |
|
1086 |
|
|
1087 |
|
|
1056 | 1088 |
if __name__ == '__main__': |
1057 | 1089 |
testutils.GanetiTestProgram() |
Also available in: Unified diff