]> granicus.if.org Git - python/commitdiff
Issue #25306: Try to fix test_huntrleaks_fd_leak() on Windows
authorVictor Stinner <victor.stinner@gmail.com>
Sat, 3 Oct 2015 19:40:21 +0000 (21:40 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Sat, 3 Oct 2015 19:40:21 +0000 (21:40 +0200)
Issue #25306: Disable popup and logs to stderr on assertion failures in MSCRT.

Lib/test/test_regrtest.py

index edbb4b0c788cdfd9def7f3010816f8c73ff326dd..2e33555afec763975765c187d65f1ecad7859f07 100644 (file)
@@ -643,14 +643,24 @@ class ArgsTestCase(BaseTestCase):
         self.check_executed_tests(output, [test]*3, failed=test)
 
     @unittest.skipUnless(Py_DEBUG, 'need a debug build')
-    # Issue #25306: the test hangs sometimes on Windows
-    @unittest.skipIf(sys.platform == 'win32', 'test broken on Windows')
     def test_huntrleaks_fd_leak(self):
         # test --huntrleaks for file descriptor leak
         code = textwrap.dedent("""
             import os
             import unittest
 
+            # Issue #25306: Disable popups and logs to stderr on assertion
+            # failures in MSCRT
+            try:
+                import msvcrt
+                msvcrt.CrtSetReportMode
+            except (ImportError, AttributeError):
+                # no Windows, o release build
+                pass
+            else:
+                for m in [msvcrt.CRT_WARN, msvcrt.CRT_ERROR, msvcrt.CRT_ASSERT]:
+                    msvcrt.CrtSetReportMode(m, 0)
+
             class FDLeakTest(unittest.TestCase):
                 def test_leak(self):
                     fd = os.open(__file__, os.O_RDONLY)