]> granicus.if.org Git - python/commitdiff
bpo-32733: Make test_coroutines robust against -Werror (GH-5487) (GH-5490)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 2 Feb 2018 05:57:28 +0000 (21:57 -0800)
committerNathaniel J. Smith <njs@pobox.com>
Fri, 2 Feb 2018 05:57:28 +0000 (21:57 -0800)
(cherry picked from commit 2efb9735899c7c642f3e75a121af82b1679577d3)

Co-authored-by: Nathaniel J. Smith <njs@pobox.com>
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: