Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-116303: Skip test module dependent tests if test modules are disabled#116307
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
encukou commentedMar 4, 2024
Would it be worth it to skip only the affected assertions, rather than the whole test method? |
erlend-aasland commentedMar 4, 2024
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 to0f6f74eCompareerlend-aasland commentedMar 4, 2024
@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. |
erlend-aasland commentedMar 5, 2024
@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
|
Uh oh!
There was an error while loading.Please reload this page.
| returnunittest.skip("_testinternalcapi required") | ||
| config=_testinternalcapi.get_config() | ||
| returnnotbool(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?
| finder=self.machinery.FileFinder(None) | ||
| self.spec=importlib.util.find_spec(self.name) | ||
| self.assertIsNotNone(self.spec) | ||
| assertself.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 thecpython branch of importlib_metadata. I do have plans to move importlib.metadata tests into their own package so they're clearly separated.
vstinner commentedMar 7, 2024
About the test_embed bug, it seems like importing |
vstinner commentedMar 7, 2024
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.cindex 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: |
vstinner commentedMar 7, 2024
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 importsubprocessprogram=r"PCbuild\amd64\_testembed_d.exe"cmd= [program,"test_repeated_init_exec","import _ctypes"]foriinrange(1,11):print(f" == Process #{i} ===")proc=subprocess.run(cmd)exitcode=proc.returncodeprint(f"=> exitcode{exitcode}")ifexitcode:break |
vstinner commentedMar 7, 2024
I created#116467 for the test_embed crash: Initialize/Finalize Python multiple time and import _ctypes each time lead to a memory corruption. |
serhiy-storchaka commentedMar 7, 2024
@vstinner, could you please open a separate issue for this and copy the results of researches there? |
erlend-aasland commentedMar 7, 2024
Thanks for your help, everyone. I'm going to close this PR and split it up in multiple parts. |
…ythonGH-116680)(cherry picked from commita254807)Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>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 commita254807)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 <jaraco@jaraco.com>
… tests (pythonGH-116680)(cherry picked from commita254807)Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>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.
Uh oh!
There was an error while loading.Please reload this page.
--disable-test-modulesis supplied #116303