]> granicus.if.org Git - python/commitdiff
Issue #24134: Use assertRaises() in context manager form in test_slice to
authorSerhiy Storchaka <storchaka@gmail.com>
Wed, 20 May 2015 15:37:37 +0000 (18:37 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Wed, 20 May 2015 15:37:37 +0000 (18:37 +0300)
avoid passing the test accidently because slice.__hash__ is None.

Lib/test/test_slice.py

index 9203d5eb19ce4701f76fa4e5a62b8202cbe010cf..1ed71f9575d417cda5565aef1e5dc6b7d53d760a 100644 (file)
@@ -80,7 +80,8 @@ class SliceTest(unittest.TestCase):
     def test_hash(self):
         # Verify clearing of SF bug #800796
         self.assertRaises(TypeError, hash, slice(5))
-        self.assertRaises(TypeError, slice(5).__hash__)
+        with self.assertRaises(TypeError):
+            slice(5).__hash__()
 
     def test_cmp(self):
         s1 = slice(1, 2, 3)