-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-35617: Fix for unittest discover not working with implicit namespace packages #11364
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
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. You can check yourself to see if the CLA has been received. Thanks again for your contribution, we look forward to reviewing it! |
else: | ||
# support for discovery from dotted module names | ||
try: | ||
__import__(start_dir) | ||
except ImportError: | ||
is_not_importable = True | ||
raise ImportError('Start directory is not importable: %r' % start_dir) |
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.
I don't know if is convenient raise a Exception here. This can break other tests
dot_import = '.'.join( | ||
os.path.relpath(start_dir, top_level_dir).split(os.sep) | ||
) | ||
__import__(dot_import) |
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.
Travis angry here :(
any chance we can get this merged in for the next release? |
5481935
to
715a5d3
Compare
https://bugs.python.org/issue35617 is closed. What is the status of this PR? |
The issue bpo-35617 was closed as duplicated of https://bugs.python.org/issue23882. The last one, seems to be fixed and have severals PRs merged. IMO this PR should be closed. The last comment was from @terryjreedy, could you give us some clues here? |
This was superseded by #29745 so closing. |
If the startdir is considered a path, then the discover function does not look for implicit namespace packages. I fixed this.
Now if the startdir is not the topdir its checked for importability (if they are the same, then it should always be importable).
If the startdir does not contain a init.py file, then its considered a implicit namespace package.
To make sure that the directories are importable I changed the code so that ImportError is raised directly when problem is discovered instead of waiting.
The PR seems to fix the problem with this, but might affect other parts that I'm not aware of.
https://bugs.python.org/issue35617