mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-23882: unittest: Drop PEP 420 support from discovery. (GH-29745)
This commit is contained in:
parent
1bee9a4625
commit
0b2b9d2513
5 changed files with 44 additions and 78 deletions
|
@ -266,8 +266,7 @@ Test Discovery
|
|||
|
||||
Unittest supports simple test discovery. In order to be compatible with test
|
||||
discovery, all of the test files must be :ref:`modules <tut-modules>` or
|
||||
:ref:`packages <tut-packages>` (including :term:`namespace packages
|
||||
<namespace package>`) importable from the top-level directory of
|
||||
:ref:`packages <tut-packages>` importable from the top-level directory of
|
||||
the project (this means that their filenames must be valid :ref:`identifiers
|
||||
<identifiers>`).
|
||||
|
||||
|
@ -340,6 +339,24 @@ the `load_tests protocol`_.
|
|||
directory too (e.g.
|
||||
``python -m unittest discover -s root/namespace -t root``).
|
||||
|
||||
.. versionchanged:: 3.11
|
||||
Python 3.11 dropped the :term:`namespace packages <namespace package>`
|
||||
support. It has been broken since Python 3.7. Start directory and
|
||||
subdirectories containing tests must be regular package that have
|
||||
``__init__.py`` file.
|
||||
|
||||
Directories containing start directory still can be a namespace package.
|
||||
In this case, you need to specify start directory as dotted package name,
|
||||
and target directory explicitly. For example::
|
||||
|
||||
# proj/ <-- current directory
|
||||
# namespace/
|
||||
# mypkg/
|
||||
# __init__.py
|
||||
# test_mypkg.py
|
||||
|
||||
python -m unittest discover -s namespace.mypkg -t .
|
||||
|
||||
|
||||
.. _organizing-tests:
|
||||
|
||||
|
@ -1858,6 +1875,10 @@ Loading and running tests
|
|||
whether their path matches *pattern*, because it is impossible for
|
||||
a package name to match the default pattern.
|
||||
|
||||
.. versionchanged:: 3.11
|
||||
*start_dir* can not be a :term:`namespace packages <namespace package>`.
|
||||
It has been broken since Python 3.7 and Python 3.11 officially remove it.
|
||||
|
||||
|
||||
The following attributes of a :class:`TestLoader` can be configured either by
|
||||
subclassing or assignment on an instance:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue