Skip to content

Test discovery should be fault tolerant and display all successfully imported files #13301

Closed
@Conchylicultor

Description

@Conchylicultor

Currently, pytest discovery fail for the entire project if a single import is missing on a single file:

E   ModuleNotFoundError: No module named 'xyz'
ERROR my_test.py
!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!
Exception: pytest discovery failed (exit code 2)

Only 1/600 file failed, but VS Code does not show the 599 tests which were correctly discovered.

Many other project have "optional" deps which add extra features. Those extra deps shouldn't be required when the full project do not need to be tested.
My project has many independent modules, each requiring a specific set of dependencies (pip install .[module0]). Contributors should not be forced to install the full dependencies of all modules / features when they only want to test a subpart.

Related issues:

Those issues are not duplicate but seems related:

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions