8000 bpo-35617: Fix for unittest discover not working with implicit namespace packages by simonfagerholm · Pull Request #11364 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

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

Closed

Conversation

simonfagerholm
Copy link
@simonfagerholm simonfagerholm commented Dec 30, 2018

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

@the-knights-who-
8000
say-ni
Copy link

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)
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Travis angry here :(

@sybohy
Copy link
sybohy commented Aug 1, 2019

any chance we can get this merged in for the next release?

@iritkatriel
Copy link
Member

https://bugs.python.org/issue35617 is closed. What is the status of this PR?

@eamanu
Copy link
Contributor
eamanu commented Apr 11, 2022

@iritkatriel

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?

@kumaraditya303
Copy link
Contributor

This was superseded by #29745 so closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants
0