summaryrefslogtreecommitdiffstats
path: root/Doc/library/unittest.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/library/unittest.rst')
-rw-r--r--Doc/library/unittest.rst35
1 files changed, 14 insertions, 21 deletions
diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst
index c49aba6..38bad94 100644
--- a/Doc/library/unittest.rst
+++ b/Doc/library/unittest.rst
@@ -340,28 +340,21 @@ Test modules and packages can customize test loading and discovery by through
the `load_tests protocol`_.
.. versionchanged:: 3.4
- Test discovery supports :term:`namespace packages <namespace package>`
- for the start directory. Note that you need to specify the top level
- directory too (e.g.
- ``python -m unittest discover -s root/namespace -t root``).
+ Test discovery supports :term:`namespace packages <namespace package>`.
.. versionchanged:: 3.11
- :mod:`unittest` dropped the :term:`namespace packages <namespace package>`
- support in Python 3.11. It has been broken since Python 3.7. Start directory and
- subdirectories containing tests must be regular package that have
- ``__init__.py`` file.
+ Test discovery dropped the :term:`namespace packages <namespace package>`
+ support. It has been broken since Python 3.7.
+ Start directory and its 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::
+ If the start directory is the dotted name of the package, the ancestor packages
+ can be namespace packages.
- # proj/ <-- current directory
- # namespace/
- # mypkg/
- # __init__.py
- # test_mypkg.py
-
- python -m unittest discover -s namespace.mypkg -t .
+.. versionchanged:: 3.14
+ Test discovery supports :term:`namespace package` as start directory again.
+ To avoid scanning directories unrelated to Python,
+ tests are not searched in subdirectories that do not contain ``__init__.py``.
.. _organizing-tests:
@@ -1915,10 +1908,8 @@ Loading and running tests
Modules that raise :exc:`SkipTest` on import are recorded as skips,
not errors.
- .. versionchanged:: 3.4
*start_dir* can be a :term:`namespace packages <namespace package>`.
- .. versionchanged:: 3.4
Paths are sorted before being imported so that execution order is the
same even if the underlying file system's ordering is not dependent
on file name.
@@ -1930,11 +1921,13 @@ Loading and running tests
.. 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.
+ It has been broken since Python 3.7, and Python 3.11 officially removes it.
.. versionchanged:: 3.13
*top_level_dir* is only stored for the duration of *discover* call.
+ .. versionchanged:: 3.14
+ *start_dir* can once again be a :term:`namespace package`.
The following attributes of a :class:`TestLoader` can be configured either by
subclassing or assignment on an instance: