File tree 2 files changed +24
-4
lines changed
Filter options
2 files changed +24
-4
lines changed
Original file line number Diff line number Diff line change @@ -41,15 +41,19 @@ class FunctionCallTestCase(unittest.TestCase):
41
41
@unittest .skipIf (sys .executable .lower ().endswith ('_d.exe' ),
42
42
"SEH not enabled in debug builds" )
43
43
def test_SEH (self ):
44
- # Call functions with invalid arguments, and make sure
45
- # that access violations are trapped and raise an
46
- # exception.
47
- self .assertRaises (OSError , windll .kernel32 .GetModuleHandleA , 32 )
44
+ # Disable faulthandler to prevent logging the warning:
45
+ # "Windows fatal exception: access violation"
46
+ with support .disable_faulthandler ():
47
+ # Call functions with invalid arguments, and make sure
48
+ # that access violations are trapped and raise an
49
+ # exception.
50
+ self .assertRaises (OSError , windll .kernel32 .GetModuleHandleA , 32 )
48
51
49
52
def test_noargs (self ):
50
53
# This is a special case on win32 x64
51
54
windll .user32 .GetDesktopWindow ()
52
55
56
+
53
57
@unittest .skipUnless (sys .platform == "win32" , 'Windows-specific test' )
54
58
class TestWintypes (unittest .TestCase ):
55
59
def test_HWND (self ):
Original file line number Diff line number Diff line change @@ -2586,3 +2586,19 @@ def setswitchinterval(interval):
2586
2586
if _is_android_emulator :
2587
2587
interval = minimum_interval
2588
2588
return sys .setswitchinterval (interval )
2589
+
2590
+
2591
+ @contextlib .contextmanager
2592
+ def disable_faulthandler ():
2593
+ # use sys.__stderr__ instead of sys.stderr, since regrtest replaces
2594
+ # sys.stderr with a StringIO which has no file descriptor when a test
2595
+ # is run with -W/--verbose3.
2596
+ fd = sys .__stderr__ .fileno ()
2597
+
2598
+ is_enabled = faulthandler .is_enabled ()
2599
+ try :
2600
+ faulthandler .disable ()
2601
+ yield
2602
+ finally :
2603
+ if is_enabled :
2604
+ faulthandler .enable (file = fd , all_threads = True )
You can’t perform that action at this time.
0 commit comments