summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/unittest.rst25
-rw-r--r--Doc/whatsnew/3.11.rst4
2 files changed, 27 insertions, 2 deletions
diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst
index 22723f4..b5a5331 100644
--- a/Doc/library/unittest.rst
+++ b/Doc/library/unittest.rst
@@ -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:
diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst
index 98ff2d4..7224361 100644
--- a/Doc/whatsnew/3.11.rst
+++ b/Doc/whatsnew/3.11.rst
@@ -542,6 +542,10 @@ Removed
(Contributed by Hugo van Kemenade in :issue:`45320`.)
+* Remove namespace package support from unittest discovery. It was introduced in
+ Python 3.4 but has been broken since Python 3.7.
+ (Contributed by Inada Naoki in :issue:`23882`.)
+
Porting to Python 3.11
======================