bpo-23882: Doc: Clarify unittest discovery document (GH-21560)

Unittest discovery support namespace package as start
directory. But it doesn't find namespace package in
the start directory automatically.

Otherwise, unittest discovery search into unexpected
directories like `vendor/` or `node_modules/`.
(cherry picked from commit 5a4aa4c03e)

Co-authored-by: Inada Naoki <songofacandy@gmail.com>
This commit is contained in:
Miss Islington (bot) 2021-02-21 22:37:18 -08:00 committed by GitHub
parent d51436f95b
commit 30fe3ee6d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -330,7 +330,9 @@ Test modules and packages can customize test loading and discovery by through
the `load_tests protocol`_. the `load_tests protocol`_.
.. versionchanged:: 3.4 .. versionchanged:: 3.4
Test discovery supports :term:`namespace packages <namespace package>`. Test discovery supports :term:`namespace packages <namespace package>`
for start directory. Note that you need to the top level directory too.
(e.g. ``python -m unittest discover -s root/namespace -t root``).
.. _organizing-tests: .. _organizing-tests:
@ -1850,10 +1852,14 @@ Loading and running tests
.. versionchanged:: 3.4 .. versionchanged:: 3.4
Modules that raise :exc:`SkipTest` on import are recorded as skips, Modules that raise :exc:`SkipTest` on import are recorded as skips,
not errors. not errors.
Discovery works for :term:`namespace packages <namespace package>`.
Paths are sorted before being imported so that execution order is .. versionchanged:: 3.4
the same even if the underlying file system's ordering is not *start_dir* can be a :term:`namespace packages <namespace package>`.
dependent on file name.
.. 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.
.. versionchanged:: 3.5 .. versionchanged:: 3.5
Found packages are now checked for ``load_tests`` regardless of Found packages are now checked for ``load_tests`` regardless of