diff options
author | Martin Panter <vadmium+py@gmail.com> | 2015-11-14 11:47:00 (GMT) |
---|---|---|
committer | Martin Panter <vadmium+py@gmail.com> | 2015-11-14 11:47:00 (GMT) |
commit | d226d308a3856e67c654ff3d5924be6d24568388 (patch) | |
tree | 54dfa13bd191781f47aa9a7d6055752b98a112fe /Doc | |
parent | 63c1ebb67b4716720ad6e807d8f6a19042af83eb (diff) | |
download | cpython-d226d308a3856e67c654ff3d5924be6d24568388.zip cpython-d226d308a3856e67c654ff3d5924be6d24568388.tar.gz cpython-d226d308a3856e67c654ff3d5924be6d24568388.tar.bz2 |
Issue #23883: Add test.support.check__all__() and test gettext.__all__
Patches by Jacek KoĆodziej.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/test.rst | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Doc/library/test.rst b/Doc/library/test.rst index 85cab3b..797afa5 100644 --- a/Doc/library/test.rst +++ b/Doc/library/test.rst @@ -580,6 +580,48 @@ The :mod:`test.support` module defines the following functions: .. versionadded:: 3.5 +.. function:: check__all__(test_case, module, name_of_module=None, extra=(), blacklist=()) + + Assert that the ``__all__`` variable of *module* contains all public names. + + The module's public names (its API) are detected automatically + based on whether they match the public name convention and were defined in + *module*. + + The *name_of_module* argument can specify (as a string or tuple thereof) what + module(s) an API could be defined in in order to be detected as a public + API. One case for this is when *module* imports part of its public API from + other modules, possibly a C backend (like ``csv`` and its ``_csv``). + + The *extra* argument can be a set of names that wouldn't otherwise be automatically + detected as "public", like objects without a proper ``__module__`` + attribute. If provided, it will be added to the automatically detected ones. + + The *blacklist* argument can be a set of names that must not be treated as part of + the public API even though their names indicate otherwise. + + Example use:: + + import bar + import foo + import unittest + from test import support + + class MiscTestCase(unittest.TestCase): + def test__all__(self): + support.check__all__(self, foo) + + class OtherTestCase(unittest.TestCase): + def test__all__(self): + extra = {'BAR_CONST', 'FOO_CONST'} + blacklist = {'baz'} # Undocumented name. + # bar imports part of its API from _bar. + support.check__all__(self, bar, ('bar', '_bar'), + extra=extra, blacklist=blacklist) + + .. versionadded:: 3.6 + + The :mod:`test.support` module defines the following classes: .. class:: TransientResource(exc, **kwargs) |