Mercurial > hg-stable
changeset 31591: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 | 985a98c6bad0 |
children | df82f375fa00 |
files | tests/test-simplekeyvaluefile.py |
diffstat | 1 files changed, 11 insertions(+), 10 deletions(-) [+] |
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__)