]> granicus.if.org Git - python/commitdiff
bpo-32733: Make test_coroutines robust against -Werror (GH-5487)
authorNathaniel J. Smith <njs@pobox.com>
Fri, 2 Feb 2018 04:55:55 +0000 (20:55 -0800)
committerGitHub <noreply@github.com>
Fri, 2 Feb 2018 04:55:55 +0000 (20:55 -0800)
Lib/test/test_coroutines.py

index f3d77192ae765f5e416a6821d95275a50108594f..b37b61b71959ee7e9a551ab11d12feb8265c0713 100644 (file)
@@ -2152,15 +2152,10 @@ class OriginTrackingTest(unittest.TestCase):
 
         def check(depth, msg):
             sys.set_coroutine_origin_tracking_depth(depth)
-            with warnings.catch_warnings(record=True) as wlist:
+            with self.assertWarns(RuntimeWarning) as cm:
                 a2()
                 support.gc_collect()
-            # This might be fragile if other warnings somehow get triggered
-            # inside our 'with' block... let's worry about that if/when it
-            # happens.
-            self.assertTrue(len(wlist) == 1)
-            self.assertIs(wlist[0].category, RuntimeWarning)
-            self.assertEqual(msg, str(wlist[0].message))
+            self.assertEqual(msg, str(cm.warning))
 
         orig_depth = sys.get_coroutine_origin_tracking_depth()
         try: