-
-
Couldn't load subscription status.
- Fork 33.2k
gh-126028: Add more tests for msvcrt module #126029
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 7 commits
71d7cc7
e14193d
f76b823
b0f2acc
a3f1546
13d4345
fee526e
c11647c
54ae00e
90b904a
79b1e6e
d70b3ce
c5c4005
62a8389
2d794f3
2fbd2e8
c3726e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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": | ||
|
|
@@ -115,6 +115,50 @@ def test_heap_min(self): | |
| except OSError: | ||
| pass | ||
|
|
||
| def test_GetErrorMode(self): | ||
| msvcrt.GetErrorMode() | ||
|
|
||
| def test_SetErrorMode(self): | ||
| old = msvcrt.GetErrorMode() | ||
| self.addCleanup(msvcrt.SetErrorMode, old) | ||
|
|
||
| returned = msvcrt.SetErrorMode(0) | ||
|
||
| self.assertIs(type(returned), int) | ||
| self.assertEqual(old, returned) | ||
|
|
||
| @unittest.skipUnless(Py_DEBUG, "only available under debug build") | ||
| def test_set_error_mode(self): | ||
| old = msvcrt.set_error_mode(msvcrt.REPORT_ERRMODE) | ||
| self.addCleanup(msvcrt.set_error_mode, old) | ||
|
|
||
| returned = msvcrt.set_error_mode(msvcrt.OUT_TO_STDERR) | ||
| self.assertIs(type(returned), int) | ||
| self.assertNotEqual(returned, -1) | ||
aisk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| self.assertEqual(old, returned) | ||
aisk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| @unittest.skipUnless(Py_DEBUG, "only available under debug build") | ||
| def test_CrtSetReportMode(self): | ||
| old = msvcrt.CrtSetReportMode(msvcrt.CRT_WARN, | ||
| msvcrt.CRTDBG_REPORT_MODE) | ||
| self.addCleanup(msvcrt.CrtSetReportMode, msvcrt.CRT_WARN, old) | ||
|
|
||
| returned = msvcrt.CrtSetReportMode(msvcrt.CRT_WARN, | ||
| msvcrt.CRTDBG_MODE_DEBUG) | ||
| self.assertIs(type(returned), int) | ||
| self.assertNotEqual(returned, -1) | ||
aisk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| self.assertEqual(old, returned) | ||
aisk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| @unittest.skipUnless(Py_DEBUG, "only available under debug build") | ||
| def test_CrtSetReportFile(self): | ||
| old = msvcrt.CrtSetReportFile(msvcrt.CRT_WARN, | ||
| msvcrt.CRTDBG_REPORT_FILE) | ||
| self.addCleanup(msvcrt.CrtSetReportFile, msvcrt.CRT_WARN, old) | ||
|
|
||
| returned = msvcrt.CrtSetReportFile(msvcrt.CRT_WARN, | ||
| msvcrt.CRTDBG_FILE_STDOUT) | ||
| self.assertIs(type(returned), int) | ||
| self.assertEqual(old, returned) | ||
aisk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() | ||
Uh oh!
There was an error while loading. Please reload this page.