Merge pull request #3439 from youknowone/relocate-sys-test

relocate wrongly placed sys test in snippets/stdlib_os.py
This commit is contained in:
Jeong YunWon
2021-11-16 02:43:28 +09:00
committed by GitHub
2 changed files with 27 additions and 27 deletions

View File

@@ -505,26 +505,3 @@ if "win" not in sys.platform:
for arg in [None, 1, 1.0, TabError]:
assert_raises(TypeError, os.system, arg)
if sys.platform.startswith("win"):
winver = sys.getwindowsversion()
# the biggest value of wSuiteMask (https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-osversioninfoexa#members).
all_masks = 0x00000004 | 0x00000400 | 0x00004000 | 0x00000080 | 0x00000002 | 0x00000040 | 0x00000200 | \
0x00000100 | 0x00000001 | 0x00000020 | 0x00002000 | 0x00000010 | 0x00008000 | 0x00020000
# We really can't test if the results are correct, so it just checks for meaningful value
assert winver.major > 0
assert winver.minor >= 0
assert winver.build > 0
assert winver.platform == 2
assert isinstance(winver.service_pack, str)
assert 0 <= winver.suite_mask <= all_masks
assert 1 <= winver.product_type <= 3
# XXX if platform_version is implemented correctly, this'll break on compatiblity mode or a build without manifest
assert winver.major == winver.platform_version[0]
assert winver.minor == winver.platform_version[1]
assert winver.build == winver.platform_version[2]

View File

@@ -51,11 +51,11 @@ assert ("demo", "call", None) in events
assert sys.exc_info() == (None, None, None)
try:
1/0
1/0
except ZeroDivisionError as exc:
exc_info = sys.exc_info()
assert exc_info[0] == type(exc) == ZeroDivisionError
assert exc_info[1] == exc
exc_info = sys.exc_info()
assert exc_info[0] == type(exc) == ZeroDivisionError
assert exc_info[1] == exc
# Recursion:
@@ -69,3 +69,26 @@ assert sys.getrecursionlimit() == 200
with assert_raises(RecursionError):
recursive_call(300)
if sys.platform.startswith("win"):
winver = sys.getwindowsversion()
print(f'winver: {winver} {winver.platform_version}')
# the biggest value of wSuiteMask (https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-osversioninfoexa#members).
all_masks = 0x00000004 | 0x00000400 | 0x00004000 | 0x00000080 | 0x00000002 | 0x00000040 | 0x00000200 | \
0x00000100 | 0x00000001 | 0x00000020 | 0x00002000 | 0x00000010 | 0x00008000 | 0x00020000
# We really can't test if the results are correct, so it just checks for meaningful value
assert winver.major > 0
assert winver.minor >= 0
assert winver.build > 0
assert winver.platform == 2
assert isinstance(winver.service_pack, str)
assert 0 <= winver.suite_mask <= all_masks
assert 1 <= winver.product_type <= 3
# XXX if platform_version is implemented correctly, this'll break on compatiblity mode or a build without manifest
# these fields can mismatch in CPython
# assert winver.major == winver.platform_version[0]
# assert winver.minor == winver.platform_version[1]
# assert winver.build == winver.platform_version[2]