python / python/cpython

unittest discovery and test.regrtest cannot find tests when they're not on the filesystem

Open
#157,144 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib tests type-feature
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Bug report

Bug description:

When the standard library is a zip archive on sys.path, the test package is not a directory: findtests() failed with an OSError from os.listdir() and load_package_tests() failed with "Start directory is not importable" from unittest discovery.

I'm still deciding if this should be done, it is perhaps odd thing to do to bundle tests into an archive before running, but this should apply to other import hooks as well and bundling tests into a zip is sort of a nice way of running tests against a fully zipped application. It's a feature regardless.

Linked PRs
  • gh-157145

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by examining unittest discovery and test.regrtest, then reproduce the failure with the standard library in a zip archive on sys.path. Done means test discovery and regrtest can locate and run tests through non-filesystem import hooks; gh-157145 is the linked PR to review first.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.