Skip to content

Commit 71d7cc7

Browse files
committed
Add more tests for msvcrt module
1 parent dad3453 commit 71d7cc7

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

Lib/test/test_msvcrt.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import unittest
55
from textwrap import dedent
66

7-
from test.support import os_helper, requires_resource
7+
from test.support import os_helper, requires_resource, Py_DEBUG
88
from test.support.os_helper import TESTFN, TESTFN_ASCII
99

1010
if sys.platform != "win32":
@@ -115,6 +115,28 @@ def test_heap_min(self):
115115
except OSError:
116116
pass
117117

118+
def test_GetErrorMode(self):
119+
msvcrt.GetErrorMode()
120+
121+
def test_SetErrorMode(self):
122+
old = msvcrt.SetErrorMode(0)
123+
msvcrt.SetErrorMode(old)
124+
125+
@unittest.skipUnless(Py_DEBUG, "only avialable under debug build")
126+
def test_set_error_mode(self):
127+
old = msvcrt.set_error_mode(msvcrt.OUT_TO_STDERR)
128+
msvcrt.set_error_mode(old)
129+
130+
@unittest.skipUnless(Py_DEBUG, "only avialable under debug build")
131+
def test_CrtSetReportMode(self):
132+
old = msvcrt.CrtSetReportMode(msvcrt.CRT_WARN, msvcrt.CRTDBG_MODE_DEBUG)
133+
msvcrt.CrtSetReportMode(msvcrt.CRT_WARN, old)
134+
135+
@unittest.skipUnless(Py_DEBUG, "only avialable under debug build")
136+
def test_CrtSetReportFile(self):
137+
old = msvcrt.CrtSetReportFile(msvcrt.CRT_WARN, sys.stdout.fileno())
138+
msvcrt.CrtSetReportFile(msvcrt.CRT_WARN, old)
139+
118140

119141
if __name__ == "__main__":
120142
unittest.main()

0 commit comments

Comments
 (0)