Mercurial > public > mercurial-scm > hg
diff tests/test-atomictempfile.py @ 32279:68c43a416585
tests: use context manager form of assertRaises
Support for using unittest.TestCase.assertRaises as a context
manager was added in Python 2.7. This form is more readable,
especially for complex tests.
While I was here, I also restored the use of assertRaisesRegexp,
which was removed in c6921568cd20 for Python 2.6 compatibility.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 13 May 2017 11:52:44 -0700 |
parents | 318a24b52eeb |
children | 3ec9afb951a0 |
line wrap: on
line diff
--- a/tests/test-atomictempfile.py Sat May 13 11:42:42 2017 -0700 +++ b/tests/test-atomictempfile.py Sat May 13 11:52:44 2017 -0700 @@ -47,7 +47,8 @@ # if a programmer screws up and passes bad args to atomictempfile, they # get a plain ordinary TypeError, not infinite recursion def testoops(self): - self.assertRaises(TypeError, atomictempfile) + with self.assertRaises(TypeError): + atomictempfile() # checkambig=True avoids ambiguity of timestamp def testcheckambig(self):