Closed akamat10 closed 1 month ago
Not sure if changlog should be updated in this situation. Let me know.
If you see the search code here, even though search_path
is passed in the previous line to fetch the finder, it doesn't get used as part of the search. This is what the above tests perhaps thought should be used. Should that be fixed?
I also think it make sense but I don't understand a lot :D feel free to push the fix you envision @akamat10 , it'll help us (me) understand better imo
Ok I tried to get _find_spec_with_path to respect the search_path
. The fix might be more involved than I thought if we don't want to rely on sys.path
for the above test. That file has some implicit dependencies on sys.path
in a few places that are going to be tricky to unravel. I think changing the sys.path
like above is the easiest thing for now to fix the tests.
I took a look at the tests within astroid repo. I see quite a few modify sys.path
before calling ast_from_module_name
. One such example is in test_manager.py here. Passing in a directory to ast_from_module_name
doesn't work (or even file I think doesn't work). Only way is through sys.path
modification. May be the documentation for that function should be updated saying it is broken (or even simplify and change the api to remove the context_file argument). The above change I have pushed for this PR can be accepted I think based on my analysis.
@akamat10 Could you rebase this so the coverage
job can pass?
@Pierre-Sassoulas Shall we merge this?
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 95.80%. Comparing base (
f448dca
) to head (96510ad
). Report is 13 commits behind head on main.
Type of Changes
Description
This PR addresses an issue with two tests (
test_wildcard_import_init
andtest_wildcard_import_non_init
) in tests/checkers/unittest_imports.py that I discovered while attempting to fix #9883.The issue with the tests is that the tests are invalid and only work due to modified
sys.path
in https://github.com/pylint-dev/pylint/blob/main/tests/pyreverse/conftest.py#L70. This can be reproduced by running the test on only the file:the above command fails and I see the following:
The fix is to augment the
sys.path
as part of the test.Refs #9883