tests: make test-simplekeyvaluefile.py py2.6-compatible
authorKostia Balytskyi <ikostia@fb.com>
Wed, 22 Mar 2017 11:26:23 -0700
changeset 31585 c6921568cd20
parent 31584 985a98c6bad0
child 31586 df82f375fa00
tests: make test-simplekeyvaluefile.py py2.6-compatible Python 2.6 unittest.TestCase does not have assertRaisesRegexp.
tests/test-simplekeyvaluefile.py
--- a/tests/test-simplekeyvaluefile.py	Thu Mar 23 20:57:27 2017 +0900
+++ b/tests/test-simplekeyvaluefile.py	Wed Mar 22 11:26:23 2017 -0700
@@ -50,23 +50,24 @@
 
     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__)