From 93a7d59bbb08729f2deb32ea6e4efd72fdc59c2c Mon Sep 17 00:00:00 2001 From: Jeong Yunwon Date: Mon, 15 Nov 2021 18:44:14 +0900 Subject: [PATCH] relocate wrongly placed sys test in snippets/stdlib_os.py --- extra_tests/snippets/stdlib_os.py | 23 ---------------------- extra_tests/snippets/stdlib_sys.py | 31 ++++++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/extra_tests/snippets/stdlib_os.py b/extra_tests/snippets/stdlib_os.py index def45bfaa6..0b75f78ccb 100644 --- a/extra_tests/snippets/stdlib_os.py +++ b/extra_tests/snippets/stdlib_os.py @@ -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] - - diff --git a/extra_tests/snippets/stdlib_sys.py b/extra_tests/snippets/stdlib_sys.py index 53df9bf607..25e3428c52 100644 --- a/extra_tests/snippets/stdlib_sys.py +++ b/extra_tests/snippets/stdlib_sys.py @@ -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]