Skip to content
Open
24 changes: 23 additions & 1 deletion Lib/test/test_msvcrt.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import unittest
from textwrap import dedent

from test.support import os_helper, requires_resource
from test.support import os_helper, requires_resource, Py_DEBUG
from test.support.os_helper import TESTFN, TESTFN_ASCII

if sys.platform != "win32":
Expand Down Expand Up @@ -115,6 +115,28 @@ def test_heap_min(self):
except OSError:
pass

def test_GetErrorMode(self):
msvcrt.GetErrorMode()

def test_SetErrorMode(self):
old = msvcrt.SetErrorMode(0)
msvcrt.SetErrorMode(old)

@unittest.skipUnless(Py_DEBUG, "only available under debug build")
def test_set_error_mode(self):
old = msvcrt.set_error_mode(msvcrt.OUT_TO_STDERR)
msvcrt.set_error_mode(old)

@unittest.skipUnless(Py_DEBUG, "only available under debug build")
def test_CrtSetReportMode(self):
old = msvcrt.CrtSetReportMode(msvcrt.CRT_WARN, msvcrt.CRTDBG_MODE_DEBUG)
msvcrt.CrtSetReportMode(msvcrt.CRT_WARN, old)

@unittest.skipUnless(Py_DEBUG, "only available under debug build")
def test_CrtSetReportFile(self):
old = msvcrt.CrtSetReportFile(msvcrt.CRT_WARN, sys.stdout.fileno())
msvcrt.CrtSetReportFile(msvcrt.CRT_WARN, old)


if __name__ == "__main__":
unittest.main()
Loading