]> granicus.if.org Git - python/commitdiff
Issue #27787: Remove test_main() and hard-coded list of test classes
authorMartin Panter <vadmium+py@gmail.com>
Tue, 23 Aug 2016 09:01:43 +0000 (09:01 +0000)
committerMartin Panter <vadmium+py@gmail.com>
Tue, 23 Aug 2016 09:01:43 +0000 (09:01 +0000)
The @reap_threads decorator made the test wait (for up to 1 s) until
background threads have finished.  Calling join() with a timeout should be
equivalent.

Lib/test/test_httplib.py

index f45e352d6af098d32537eaf8a072dc5a744cd049..5c500cbc46a8da9a6d09e272bc22efa5c395cc3d 100644 (file)
@@ -940,6 +940,7 @@ class BasicTest(TestCase):
 
         thread = threading.Thread(target=run_server)
         thread.start()
+        self.addCleanup(thread.join, float(1))
         conn = client.HTTPConnection(*serv.getsockname())
         conn.request("CONNECT", "dummy:1234")
         response = conn.getresponse()
@@ -953,7 +954,7 @@ class BasicTest(TestCase):
         finally:
             response.close()
             conn.close()
-            thread.join()
+        thread.join()
         self.assertEqual(result, b"proxied data\n")
 
 class ExtendedReadTest(TestCase):
@@ -1711,13 +1712,5 @@ class TunnelTests(TestCase):
         self.assertIn('header: {}'.format(expected_header), lines)
 
 
-@support.reap_threads
-def test_main(verbose=None):
-    support.run_unittest(HeaderTests, OfflineTest, BasicTest, TimeoutTest,
-                         PersistenceTest,
-                         HTTPSTest, RequestBodyTest, SourceAddressTest,
-                         HTTPResponseTest, ExtendedReadTest,
-                         ExtendedReadTestChunked, TunnelTests)
-
 if __name__ == '__main__':
     test_main()