From 606d8196b623abfb6f27f72ffd93e5876e25348c Mon Sep 17 00:00:00 2001 From: Noah <33094578+coolreader18@users.noreply.github.com> Date: Mon, 2 Nov 2020 01:21:32 -0600 Subject: [PATCH] Skip some importlib tests on windows + fix weird errors, hopefully? --- Lib/pathlib.py | 5 ++++- Lib/test/support/__init__.py | 15 +++++++++------ Lib/test/test_importlib/test_windows.py | 2 ++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Lib/pathlib.py b/Lib/pathlib.py index 059672999..da8166d40 100644 --- a/Lib/pathlib.py +++ b/Lib/pathlib.py @@ -43,7 +43,10 @@ _IGNORED_WINERRORS = ( ) def _ignore_error(exception): - return (getattr(exception, 'errno', None) in _IGNORED_ERROS or + # XXX RUSTPYTHON: added check for FileNotFoundError, file.exists() on windows throws it + # but with a errno==ESRCH for some reason + return (isinstance(exception, FileNotFoundError) or + getattr(exception, 'errno', None) in _IGNORED_ERROS or getattr(exception, 'winerror', None) in _IGNORED_WINERRORS) diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 6c634ccd8..f12e8bbbd 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -1066,12 +1066,15 @@ def temp_dir(path=None, quiet=False): try: rmtree(path) except OSError as exc: - # XXX RUSTPYTHON: added quiet check here, not sure why rmtree fails on windows - if not quiet: - raise - warnings.warn(f'unable to remove temporary' - f'directory {path!r}: {exc}', - RuntimeWarning, stacklevel=3) + # XXX RUSTPYTHON: something something async file removal? + # also part of the thing with rmtree() + # throwing PermissionError, I think + if os.path.exists(path): + if not quiet: + raise + warnings.warn(f'unable to remove temporary' + f'directory {path!r}: {exc}', + RuntimeWarning, stacklevel=3) @contextlib.contextmanager def change_cwd(path, quiet=False): diff --git a/Lib/test/test_importlib/test_windows.py b/Lib/test/test_importlib/test_windows.py index 005b685cc..08709d431 100644 --- a/Lib/test/test_importlib/test_windows.py +++ b/Lib/test/test_importlib/test_windows.py @@ -88,6 +88,8 @@ class WindowsRegistryFinderTests: @unittest.skipUnless(sys.platform.startswith('win'), 'requires Windows') class WindowsExtensionSuffixTests: + # TODO: RUSTPYTHON + @unittest.expectedFailure def test_tagged_suffix(self): suffixes = self.machinery.EXTENSION_SUFFIXES expected_tag = ".cp{0.major}{0.minor}-{1}.pyd".format(sys.version_info,