Skip to content

Commit

Permalink
Fix py2 incompatible usage of assertRaises
Browse files Browse the repository at this point in the history
Officially, assertRaises can be called as context manager starting in
python3, even though it seems the tests are passing, so I guess it was
backported some time later, but we can't really rely on that.
  • Loading branch information
coldfix committed Sep 6, 2018
1 parent ab548e3 commit 31e103f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tests/test_magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ def test_hash_obj(self):
self.assertEqual(hash(mod.Foo()), 1234)
self.assertEqual(hash(mod.Bar()), 1234)
if is_py3:
with self.assertRaises(TypeError):
hash(mod.Mux())
# py3 implicitly adds '__hash__=None' during class construction
# if '__eq__ is defined:
self.assertRaises(TypeError, lambda: hash(mod.Mux()))
else:
self.assertEqual(hash(mod.Mux()), 1234)

Expand Down

0 comments on commit 31e103f

Please sign in to comment.