Mercurial > hg
diff tests/test-simplekeyvaluefile.py @ 31585:c6921568cd20
tests: make test-simplekeyvaluefile.py py2.6-compatible
Python 2.6 unittest.TestCase does not have assertRaisesRegexp.
author | Kostia Balytskyi <ikostia@fb.com> |
---|---|
date | Wed, 22 Mar 2017 11:26:23 -0700 |
parents | 56acc4250900 |
children | ed2c44741190 |
line wrap: on
line diff
--- 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__)