[PATCH] tests: make test-simplekeyvaluefile.py py2.6-compatible

Kostia Balytskyi ikostia at fb.com
Thu Mar 23 06:25:59 EDT 2017


# HG changeset patch
# User Kostia Balytskyi <ikostia at fb.com>
# Date 1490207183 25200
#      Wed Mar 22 11:26:23 2017 -0700
# Node ID 5d11feaf6bf6dc0a15d5fa3ac34fe48fd31233e6
# Parent  55c6788c54e2faf80ec14f2b0844bfe429012bc3
tests: make test-simplekeyvaluefile.py py2.6-compatible

Python 2.6 unittest.TestCase does not have assertRaisesRegexp.

diff --git a/tests/test-simplekeyvaluefile.py b/tests/test-simplekeyvaluefile.py
--- a/tests/test-simplekeyvaluefile.py
+++ b/tests/test-simplekeyvaluefile.py
@@ -50,23 +50,24 @@ class testsimplekeyvaluefile(unittest.Te
 
     def testinvalidkeys(self):
         d = {'0key1': 'value1', 'Key2': 'value2'}
-        with self.assertRaisesRegexp(error.ProgrammingError,
-                                     "keys must start with a letter.*"):
-            scmutil.simplekeyvaluefile(self.vfs, 'kvfile').write(d)
+        self.assertRaises(error.ProgrammingError,
+                          scmutil.simplekeyvaluefile(self.vfs, 'kvfile').write,
+                          d)
         d = {'key1@': 'value1', 'Key2': 'value2'}
-        with self.assertRaisesRegexp(error.ProgrammingError, "invalid key.*"):
-            scmutil.simplekeyvaluefile(self.vfs, 'kvfile').write(d)
+        self.assertRaises(error.ProgrammingError,
+                          scmutil.simplekeyvaluefile(self.vfs, 'kvfile').write,
+                          d)
 
     def testinvalidvalues(self):
         d = {'key1': 'value1', 'Key2': 'value2\n'}
-        with self.assertRaisesRegexp(error.ProgrammingError, "invalid val.*"):
-            scmutil.simplekeyvaluefile(self.vfs, 'kvfile').write(d)
+        self.assertRaises(error.ProgrammingError,
+                          scmutil.simplekeyvaluefile(self.vfs, 'kvfile').write,
+                          d)
 
     def testcorruptedfile(self):
         self.vfs.contents['badfile'] = 'ababagalamaga\n'
-        with self.assertRaisesRegexp(error.CorruptedState,
-                                     "dictionary.*element.*"):
-            scmutil.simplekeyvaluefile(self.vfs, 'badfile').read()
+        self.assertRaises(error.CorruptedState,
+                          scmutil.simplekeyvaluefile(self.vfs, 'badfile').read)
 
 if __name__ == "__main__":
     silenttestrunner.main(__name__)


More information about the Mercurial-devel mailing list