Show More
@@ -426,6 +426,7 b' test-show-stack.t' | |||||
426 | test-show-work.t |
|
426 | test-show-work.t | |
427 | test-show.t |
|
427 | test-show.t | |
428 | test-simple-update.t |
|
428 | test-simple-update.t | |
|
429 | test-simplekeyvaluefile.py | |||
429 | test-simplemerge.py |
|
430 | test-simplemerge.py | |
430 | test-single-head.t |
|
431 | test-single-head.t | |
431 | test-sparse-clear.t |
|
432 | test-sparse-clear.t |
@@ -44,11 +44,11 b' class testsimplekeyvaluefile(unittest.Te' | |||||
44 | self.vfs = mockvfs() |
|
44 | self.vfs = mockvfs() | |
45 |
|
45 | |||
46 | def testbasicwritingiandreading(self): |
|
46 | def testbasicwritingiandreading(self): | |
47 | dw = {'key1': 'value1', 'Key2': 'value2'} |
|
47 | dw = {b'key1': b'value1', b'Key2': b'value2'} | |
48 | scmutil.simplekeyvaluefile(self.vfs, 'kvfile').write(dw) |
|
48 | scmutil.simplekeyvaluefile(self.vfs, b'kvfile').write(dw) | |
49 | self.assertEqual(sorted(self.vfs.read('kvfile').split('\n')), |
|
49 | self.assertEqual(sorted(self.vfs.read(b'kvfile').split(b'\n')), | |
50 | ['', 'Key2=value2', 'key1=value1']) |
|
50 | [b'', b'Key2=value2', b'key1=value1']) | |
51 | dr = scmutil.simplekeyvaluefile(self.vfs, 'kvfile').read() |
|
51 | dr = scmutil.simplekeyvaluefile(self.vfs, b'kvfile').read() | |
52 | self.assertEqual(dr, dw) |
|
52 | self.assertEqual(dr, dw) | |
53 |
|
53 | |||
54 | if not getattr(unittest.TestCase, 'assertRaisesRegex', False): |
|
54 | if not getattr(unittest.TestCase, 'assertRaisesRegex', False): | |
@@ -58,33 +58,33 b' class testsimplekeyvaluefile(unittest.Te' | |||||
58 | unittest.TestCase.assertRaisesRegexp) |
|
58 | unittest.TestCase.assertRaisesRegexp) | |
59 |
|
59 | |||
60 | def testinvalidkeys(self): |
|
60 | def testinvalidkeys(self): | |
61 | d = {'0key1': 'value1', 'Key2': 'value2'} |
|
61 | d = {b'0key1': b'value1', b'Key2': b'value2'} | |
62 | with self.assertRaisesRegex(error.ProgrammingError, |
|
62 | with self.assertRaisesRegex(error.ProgrammingError, | |
63 | 'keys must start with a letter.*'): |
|
63 | 'keys must start with a letter.*'): | |
64 | scmutil.simplekeyvaluefile(self.vfs, 'kvfile').write(d) |
|
64 | scmutil.simplekeyvaluefile(self.vfs, b'kvfile').write(d) | |
65 |
|
65 | |||
66 | d = {'key1@': 'value1', 'Key2': 'value2'} |
|
66 | d = {b'key1@': b'value1', b'Key2': b'value2'} | |
67 | with self.assertRaisesRegex(error.ProgrammingError, 'invalid key.*'): |
|
67 | with self.assertRaisesRegex(error.ProgrammingError, 'invalid key.*'): | |
68 | scmutil.simplekeyvaluefile(self.vfs, 'kvfile').write(d) |
|
68 | scmutil.simplekeyvaluefile(self.vfs, b'kvfile').write(d) | |
69 |
|
69 | |||
70 | def testinvalidvalues(self): |
|
70 | def testinvalidvalues(self): | |
71 | d = {'key1': 'value1', 'Key2': 'value2\n'} |
|
71 | d = {b'key1': b'value1', b'Key2': b'value2\n'} | |
72 | with self.assertRaisesRegex(error.ProgrammingError, 'invalid val.*'): |
|
72 | with self.assertRaisesRegex(error.ProgrammingError, 'invalid val.*'): | |
73 | scmutil.simplekeyvaluefile(self.vfs, 'kvfile').write(d) |
|
73 | scmutil.simplekeyvaluefile(self.vfs, b'kvfile').write(d) | |
74 |
|
74 | |||
75 | def testcorruptedfile(self): |
|
75 | def testcorruptedfile(self): | |
76 | self.vfs.contents['badfile'] = 'ababagalamaga\n' |
|
76 | self.vfs.contents[b'badfile'] = b'ababagalamaga\n' | |
77 | with self.assertRaisesRegex(error.CorruptedState, |
|
77 | with self.assertRaisesRegex(error.CorruptedState, | |
78 | 'dictionary.*element.*'): |
|
78 | 'dictionary.*element.*'): | |
79 | scmutil.simplekeyvaluefile(self.vfs, 'badfile').read() |
|
79 | scmutil.simplekeyvaluefile(self.vfs, b'badfile').read() | |
80 |
|
80 | |||
81 | def testfirstline(self): |
|
81 | def testfirstline(self): | |
82 | dw = {'key1': 'value1'} |
|
82 | dw = {b'key1': b'value1'} | |
83 | scmutil.simplekeyvaluefile(self.vfs, 'fl').write(dw, firstline='1.0') |
|
83 | scmutil.simplekeyvaluefile(self.vfs, b'fl').write(dw, firstline=b'1.0') | |
84 | self.assertEqual(self.vfs.read('fl'), '1.0\nkey1=value1\n') |
|
84 | self.assertEqual(self.vfs.read(b'fl'), b'1.0\nkey1=value1\n') | |
85 | dr = scmutil.simplekeyvaluefile(self.vfs, 'fl')\ |
|
85 | dr = scmutil.simplekeyvaluefile(self.vfs, b'fl')\ | |
86 | .read(firstlinenonkeyval=True) |
|
86 | .read(firstlinenonkeyval=True) | |
87 | self.assertEqual(dr, {'__firstline': '1.0', 'key1': 'value1'}) |
|
87 | self.assertEqual(dr, {b'__firstline': b'1.0', b'key1': b'value1'}) | |
88 |
|
88 | |||
89 | if __name__ == "__main__": |
|
89 | if __name__ == "__main__": | |
90 | silenttestrunner.main(__name__) |
|
90 | silenttestrunner.main(__name__) |
General Comments 0
You need to be logged in to leave comments.
Login now