]> granicus.if.org Git - python/commitdiff
Issue #23919: Prevents assert dialogs appearing in the test suite.
authorSteve Dower <steve.dower@microsoft.com>
Thu, 8 Oct 2015 16:05:36 +0000 (09:05 -0700)
committerSteve Dower <steve.dower@microsoft.com>
Thu, 8 Oct 2015 16:05:36 +0000 (09:05 -0700)
Lib/test/libregrtest/cmdline.py
Lib/test/libregrtest/setup.py

index 6b18b3a9b77775ccbd45b2fcc302489679ee09c3..21c3e66b5473ca32cea7bf4b62976fdc40221edd 100644 (file)
@@ -304,6 +304,10 @@ def _parse_args(args, **kwargs):
     if ns.pgo and (ns.verbose or ns.verbose2 or ns.verbose3):
         parser.error("--pgo/-v don't go together!")
 
+    if ns.nowindows:
+        print("Warning: the --nowindows (-n) option is deprecated. "
+              "Use -vv to display assertions in stderr.", file=sys.stderr)
+
     if ns.quiet:
         ns.verbose = 0
     if ns.timeout is not None:
index 6a1c308ecfa90f29789d2bc8c3317185679a0328..6e05c7e6ffaf8bdc7752cb2f25cde7e505c2aebb 100644 (file)
@@ -75,8 +75,11 @@ def setup_tests(ns):
     if ns.threshold is not None:
         gc.set_threshold(ns.threshold)
 
-    if ns.nowindows:
+    try:
         import msvcrt
+    except ImportError:
+        pass
+    else:
         msvcrt.SetErrorMode(msvcrt.SEM_FAILCRITICALERRORS|
                             msvcrt.SEM_NOALIGNMENTFAULTEXCEPT|
                             msvcrt.SEM_NOGPFAULTERRORBOX|
@@ -88,8 +91,11 @@ def setup_tests(ns):
             pass
         else:
             for m in [msvcrt.CRT_WARN, msvcrt.CRT_ERROR, msvcrt.CRT_ASSERT]:
-                msvcrt.CrtSetReportMode(m, msvcrt.CRTDBG_MODE_FILE)
-                msvcrt.CrtSetReportFile(m, msvcrt.CRTDBG_FILE_STDERR)
+                if ns.verbose and ns.verbose >= 2:
+                    msvcrt.CrtSetReportMode(m, msvcrt.CRTDBG_MODE_FILE)
+                    msvcrt.CrtSetReportFile(m, msvcrt.CRTDBG_FILE_STDERR)
+                else:
+                    msvcrt.CrtSetReportMode(m, 0)
 
     support.use_resources = ns.use_resources