Issue #23883: Add test.support.check__all__() and test gettext.__all__

Patches by Jacek KoƂodziej.
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 @@
    .. 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)