-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
gh-116303: Skip test module dependent tests if test modules are disabled #116307
Conversation
Would it be worth it to skip only the affected assertions, rather than the whole test method? |
Yes, I think so. I'll split them up. |
- Lib/test/support/__init__.py - Lib/test/test_audit.py - Lib/test/test_gdb/test_misc.py - Lib/test/test_inspect/test_inspect.py - Lib/test/test_pydoc/test_pydoc.py
ee6047c
to
0f6f74e
Compare
@encukou: I started fixing some of the remaining tests, but I won't be back at my laptop until tonight. Feel free to pick this up in the mean time. |
@serhiy-storchaka, would you like to join in on finishing this PR? There are still a lot of test failures1, but I'm slowly getting there. For example, Footnotes
|
return unittest.skip("_testinternalcapi required") | ||
config = _testinternalcapi.get_config() | ||
return not bool(config['code_debug_ranges']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does it return a boolean (which is not callable) or a function (which always true)? How this helper is supposed to be used?
@@ -108,7 +108,7 @@ def setUp(self): | |||
) | |||
finder = self.machinery.FileFinder(None) | |||
self.spec = importlib.util.find_spec(self.name) | |||
self.assertIsNotNone(self.spec) | |||
assert self.spec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why skip this in optimized mode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaraco requested to leave the assert's for importlib tests, so I reverted the unittest assert style changes. The code is shared with an external repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI - I only care about the retention of bare asserts in the tests for importlib.metadata and importlib.resources. Unfortunately, the tests for importlib.metadata are interspersed with other importlib tests, so it's not easy to know which are which without looking at the cpython branch of importlib_metadata. I do have plans to move importlib.metadata tests into their own package so they're clearly separated.
About the test_embed bug, it seems like importing
|
I can reproduce the bug on the main branch, without these changes. Use this patch to make the bug more likely: diff --git a/Programs/_testembed.c b/Programs/_testembed.c
index 30998bf80f..e8f36ae442 100644
--- a/Programs/_testembed.c
+++ b/Programs/_testembed.c
@@ -38,7 +38,7 @@ char **main_argv;
/* Use path starting with "./" avoids a search along the PATH */
#define PROGRAM_NAME L"./_testembed"
-#define INIT_LOOPS 4
+#define INIT_LOOPS 12
// Ignore Py_DEPRECATED() compiler warnings: deprecated functions are
// tested on purpose here.
Example of crash:
|
I tried to dig into Python history: the bug exists since July 1st, 2023 at least. I failed to go further in the past with
Latest version of my import subprocess
program = r"PCbuild\amd64\_testembed_d.exe"
cmd = [program, "test_repeated_init_exec", "import _ctypes"]
for i in range(1, 11):
print(f" == Process #{i} ===")
proc = subprocess.run(cmd)
exitcode = proc.returncode
print(f"=> exitcode {exitcode}")
if exitcode:
break |
I created #116467 for the test_embed crash: Initialize/Finalize Python multiple time and import _ctypes each time lead to a memory corruption. |
@vstinner, could you please open a separate issue for this and copy the results of researches there? |
Thanks for your help, everyone. I'm going to close this PR and split it up in multiple parts. |
…ythonGH-116680) (cherry picked from commit a254807) Co-authored-by: Jason R. Coombs <[email protected]> pythongh-116307: Create a new import helper 'isolated modules' and use that instead of 'Clean Import' to ensure that tests from importlib_resources don't leave modules in sys.modules.
… tests (pythonGH-116680) (python#116684) pythongh-116307: Proper fix for 'mod' leaking across importlib tests (pythonGH-116680) (cherry picked from commit a254807) pythongh-116307: Create a new import helper 'isolated modules' and use that instead of 'Clean Import' to ensure that tests from importlib_resources don't leave modules in sys.modules. Co-authored-by: Jason R. Coombs <[email protected]>
#116694) [3.11] gh-116307: Proper fix for 'mod' leaking across importlib tests (GH-116680) (cherry picked from commit a254807) gh-116307: Create a new import helper 'isolated modules' and use that instead of 'Clean Import' to ensure that tests from importlib_resources don't leave modules in sys.modules.
… tests (pythonGH-116680) (cherry picked from commit a254807) Co-authored-by: Jason R. Coombs <[email protected]> pythongh-116307: Create a new import helper 'isolated modules' and use that instead of 'Clean Import' to ensure that tests from importlib_resources don't leave modules in sys.modules.
…ython#116680) pythongh-116307: Create a new import helper 'isolated modules' and use that instead of 'Clean Import' to ensure that tests from importlib_resources don't leave modules in sys.modules.
…ython#116680) pythongh-116307: Create a new import helper 'isolated modules' and use that instead of 'Clean Import' to ensure that tests from importlib_resources don't leave modules in sys.modules.
…ython#116680) pythongh-116307: Create a new import helper 'isolated modules' and use that instead of 'Clean Import' to ensure that tests from importlib_resources don't leave modules in sys.modules.
--disable-test-modules
is supplied #116303