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
unittest fails with "Start directory is not importable" when trying to run sourceless tests #71046
Comments
unittest fails to load tests when the tests are in a package that has an __init__.pyc file and no __init__.py file. Patch attached. |
Is this the same bug as bpo-26481? I.e. is it the unittest dicovery mode that is affected? Maybe close the other bug as a duplicate, since Xavier has provided a patch here. |
It seems to be the same bug. Source-less distributions are useful on mobile devices where space is sparse. |
Could you please add a test case. |
Here is the patch with a test case. |
Thanks for the review Pamela, indeed self.vfs is not defined. The patched test_unittest runs without failure because the list_dir() nested function is never called. It is also never called in the un-patched version. Actually the un-patched test_discover_start_dir_is_package_calls_package_load_tests runs without failure when changing '__init__.py' of vfs to 'foo' or whatever :( |
This new patch does not use vfs and list_dir and uses subtests to also check that TestLoader.discover() does consider that a path refers to a package directory when it contains an '__init__.pyc' file and no '__init__.py' file, and vice-versa. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: