bpo-41521: Rename blacklist parameter to not_exported (GH-21824)

Rename "blacklist" parameter of test.support.check__all__() to
"not_exported".
This commit is contained in:
Victor Stinner 2020-08-17 07:20:40 +02:00 committed by GitHub
parent 97003466d4
commit fbf43f051e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 98 additions and 97 deletions

View File

@ -878,7 +878,7 @@ The :mod:`test.support` module defines the following functions:
missing. missing.
.. function:: check__all__(test_case, module, name_of_module=None, extra=(), blacklist=()) .. function:: check__all__(test_case, module, name_of_module=None, extra=(), not_exported=())
Assert that the ``__all__`` variable of *module* contains all public names. Assert that the ``__all__`` variable of *module* contains all public names.
@ -895,8 +895,8 @@ The :mod:`test.support` module defines the following functions:
detected as "public", like objects without a proper ``__module__`` detected as "public", like objects without a proper ``__module__``
attribute. If provided, it will be added to the automatically detected ones. 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 *not_exported* argument can be a set of names that must not be treated
the public API even though their names indicate otherwise. as part of the public API even though their names indicate otherwise.
Example use:: Example use::
@ -912,10 +912,10 @@ The :mod:`test.support` module defines the following functions:
class OtherTestCase(unittest.TestCase): class OtherTestCase(unittest.TestCase):
def test__all__(self): def test__all__(self):
extra = {'BAR_CONST', 'FOO_CONST'} extra = {'BAR_CONST', 'FOO_CONST'}
blacklist = {'baz'} # Undocumented name. not_exported = {'baz'} # Undocumented name.
# bar imports part of its API from _bar. # bar imports part of its API from _bar.
support.check__all__(self, bar, ('bar', '_bar'), support.check__all__(self, bar, ('bar', '_bar'),
extra=extra, blacklist=blacklist) extra=extra, not_exported=not_exported)
.. versionadded:: 3.6 .. versionadded:: 3.6

View File

@ -5581,9 +5581,11 @@ class TestSyncManagerTypes(unittest.TestCase):
class MiscTestCase(unittest.TestCase): class MiscTestCase(unittest.TestCase):
def test__all__(self): def test__all__(self):
# Just make sure names in blacklist are excluded # Just make sure names in not_exported are excluded
support.check__all__(self, multiprocessing, extra=multiprocessing.__all__, support.check__all__(self, multiprocessing, extra=multiprocessing.__all__,
blacklist=['SUBDEBUG', 'SUBWARNING']) not_exported=['SUBDEBUG', 'SUBWARNING'])
# #
# Mixins # Mixins
# #

View File

@ -1410,7 +1410,7 @@ def detect_api_mismatch(ref_api, other_api, *, ignore=()):
def check__all__(test_case, module, name_of_module=None, extra=(), def check__all__(test_case, module, name_of_module=None, extra=(),
blacklist=()): not_exported=()):
"""Assert that the __all__ variable of 'module' contains all public names. """Assert that the __all__ variable of 'module' contains all public names.
The module's public names (its API) are detected automatically based on The module's public names (its API) are detected automatically based on
@ -1427,7 +1427,7 @@ def check__all__(test_case, module, name_of_module=None, extra=(),
'__module__' attribute. If provided, it will be added to the '__module__' attribute. If provided, it will be added to the
automatically detected ones. automatically detected ones.
The 'blacklist' argument can be a set of names that must not be treated The 'not_exported' argument can be a set of names that must not be treated
as part of the public API even though their names indicate otherwise. as part of the public API even though their names indicate otherwise.
Usage: Usage:
@ -1443,10 +1443,10 @@ def check__all__(test_case, module, name_of_module=None, extra=(),
class OtherTestCase(unittest.TestCase): class OtherTestCase(unittest.TestCase):
def test__all__(self): def test__all__(self):
extra = {'BAR_CONST', 'FOO_CONST'} extra = {'BAR_CONST', 'FOO_CONST'}
blacklist = {'baz'} # Undocumented name. not_exported = {'baz'} # Undocumented name.
# bar imports part of its API from _bar. # bar imports part of its API from _bar.
support.check__all__(self, bar, ('bar', '_bar'), support.check__all__(self, bar, ('bar', '_bar'),
extra=extra, blacklist=blacklist) extra=extra, not_exported=not_exported)
""" """
@ -1458,7 +1458,7 @@ def check__all__(test_case, module, name_of_module=None, extra=(),
expected = set(extra) expected = set(extra)
for name in dir(module): for name in dir(module):
if name.startswith('_') or name in blacklist: if name.startswith('_') or name in not_exported:
continue continue
obj = getattr(module, name) obj = getattr(module, name)
if (getattr(obj, '__module__', None) in name_of_module or if (getattr(obj, '__module__', None) in name_of_module or

View File

@ -934,12 +934,12 @@ class CommandLineTestCase(unittest.TestCase):
class MiscTestCase(unittest.TestCase): class MiscTestCase(unittest.TestCase):
def test__all__(self): def test__all__(self):
blacklist = {'mdays', 'January', 'February', 'EPOCH', not_exported = {
'MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'mdays', 'January', 'February', 'EPOCH', 'MONDAY', 'TUESDAY',
'SATURDAY', 'SUNDAY', 'different_locale', 'c', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY', 'SUNDAY',
'prweek', 'week', 'format', 'formatstring', 'main', 'different_locale', 'c', 'prweek', 'week', 'format',
'monthlen', 'prevmonth', 'nextmonth'} 'formatstring', 'main', 'monthlen', 'prevmonth', 'nextmonth'}
support.check__all__(self, calendar, blacklist=blacklist) support.check__all__(self, calendar, not_exported=not_exported)
class TestSubClassingCase(unittest.TestCase): class TestSubClassingCase(unittest.TestCase):

View File

@ -553,9 +553,10 @@ this is the content of the fake file
("form-data", {"name": "files", "filename": 'fo"o;bar'})) ("form-data", {"name": "files", "filename": 'fo"o;bar'}))
def test_all(self): def test_all(self):
blacklist = {"logfile", "logfp", "initlog", "dolog", "nolog", not_exported = {
"closelog", "log", "maxlen", "valid_boundary"} "logfile", "logfp", "initlog", "dolog", "nolog", "closelog", "log",
support.check__all__(self, cgi, blacklist=blacklist) "maxlen", "valid_boundary"}
support.check__all__(self, cgi, not_exported=not_exported)
BOUNDARY = "---------------------------721837373350705526688164684" BOUNDARY = "---------------------------721837373350705526688164684"

View File

@ -2128,8 +2128,7 @@ class BlatantOverrideConvertersTestCase(unittest.TestCase):
class MiscTestCase(unittest.TestCase): class MiscTestCase(unittest.TestCase):
def test__all__(self): def test__all__(self):
blacklist = {"Error"} support.check__all__(self, configparser, not_exported={"Error"})
support.check__all__(self, configparser, blacklist=blacklist)
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -1107,10 +1107,11 @@ class TestTimeouts(TestCase):
class MiscTestCase(TestCase): class MiscTestCase(TestCase):
def test__all__(self): def test__all__(self):
blacklist = {'MSG_OOB', 'FTP_PORT', 'MAXLINE', 'CRLF', 'B_CRLF', not_exported = {
'Error', 'parse150', 'parse227', 'parse229', 'parse257', 'MSG_OOB', 'FTP_PORT', 'MAXLINE', 'CRLF', 'B_CRLF', 'Error',
'print_line', 'ftpcp', 'test'} 'parse150', 'parse227', 'parse229', 'parse257', 'print_line',
support.check__all__(self, ftplib, blacklist=blacklist) 'ftpcp', 'test'}
support.check__all__(self, ftplib, not_exported=not_exported)
def test_main(): def test_main():

View File

@ -820,8 +820,8 @@ class GettextCacheTestCase(GettextBaseTest):
class MiscTestCase(unittest.TestCase): class MiscTestCase(unittest.TestCase):
def test__all__(self): def test__all__(self):
blacklist = {'c2py', 'ENOENT'} support.check__all__(self, gettext,
support.check__all__(self, gettext, blacklist=blacklist) not_exported={'c2py', 'ENOENT'})
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -5363,12 +5363,12 @@ class NTEventLogHandlerTest(BaseTest):
class MiscTestCase(unittest.TestCase): class MiscTestCase(unittest.TestCase):
def test__all__(self): def test__all__(self):
blacklist = {'logThreads', 'logMultiprocessing', not_exported = {
'logProcesses', 'currentframe', 'logThreads', 'logMultiprocessing', 'logProcesses', 'currentframe',
'PercentStyle', 'StrFormatStyle', 'StringTemplateStyle', 'PercentStyle', 'StrFormatStyle', 'StringTemplateStyle',
'Filterer', 'PlaceHolder', 'Manager', 'RootLogger', 'Filterer', 'PlaceHolder', 'Manager', 'RootLogger', 'root',
'root', 'threading'} 'threading'}
support.check__all__(self, logging, blacklist=blacklist) support.check__all__(self, logging, not_exported=not_exported)
# Set the locale to the platform-dependent default. I have no idea # Set the locale to the platform-dependent default. I have no idea

View File

@ -2296,8 +2296,8 @@ Gregory K. Johnson
class MiscTestCase(unittest.TestCase): class MiscTestCase(unittest.TestCase):
def test__all__(self): def test__all__(self):
blacklist = {"linesep", "fcntl"} support.check__all__(self, mailbox,
support.check__all__(self, mailbox, blacklist=blacklist) not_exported={"linesep", "fcntl"})
def test_main(): def test_main():

View File

@ -1652,8 +1652,8 @@ class TestParseNumber(BaseTest):
class MiscTestCase(unittest.TestCase): class MiscTestCase(unittest.TestCase):
def test__all__(self): def test__all__(self):
blacklist = {'check_builtin', 'AmbiguousOptionError', 'NO_DEFAULT'} not_exported = {'check_builtin', 'AmbiguousOptionError', 'NO_DEFAULT'}
support.check__all__(self, optparse, blacklist=blacklist) support.check__all__(self, optparse, not_exported=not_exported)
def test_main(): def test_main():

View File

@ -63,34 +63,35 @@ class OptimizedPickleTests(AbstractPickleTests):
class MiscTestCase(unittest.TestCase): class MiscTestCase(unittest.TestCase):
def test__all__(self): def test__all__(self):
blacklist = {'bytes_types', not_exported = {
'UP_TO_NEWLINE', 'TAKEN_FROM_ARGUMENT1', 'bytes_types',
'TAKEN_FROM_ARGUMENT4', 'TAKEN_FROM_ARGUMENT4U', 'UP_TO_NEWLINE', 'TAKEN_FROM_ARGUMENT1',
'TAKEN_FROM_ARGUMENT8U', 'ArgumentDescriptor', 'TAKEN_FROM_ARGUMENT4', 'TAKEN_FROM_ARGUMENT4U',
'read_uint1', 'read_uint2', 'read_int4', 'read_uint4', 'TAKEN_FROM_ARGUMENT8U', 'ArgumentDescriptor',
'read_uint8', 'read_stringnl', 'read_stringnl_noescape', 'read_uint1', 'read_uint2', 'read_int4', 'read_uint4',
'read_stringnl_noescape_pair', 'read_string1', 'read_uint8', 'read_stringnl', 'read_stringnl_noescape',
'read_string4', 'read_bytes1', 'read_bytes4', 'read_stringnl_noescape_pair', 'read_string1',
'read_bytes8', 'read_bytearray8', 'read_unicodestringnl', 'read_string4', 'read_bytes1', 'read_bytes4',
'read_unicodestring1', 'read_unicodestring4', 'read_bytes8', 'read_bytearray8', 'read_unicodestringnl',
'read_unicodestring8', 'read_decimalnl_short', 'read_unicodestring1', 'read_unicodestring4',
'read_decimalnl_long', 'read_floatnl', 'read_float8', 'read_unicodestring8', 'read_decimalnl_short',
'read_long1', 'read_long4', 'read_decimalnl_long', 'read_floatnl', 'read_float8',
'uint1', 'uint2', 'int4', 'uint4', 'uint8', 'stringnl', 'read_long1', 'read_long4',
'stringnl_noescape', 'stringnl_noescape_pair', 'string1', 'uint1', 'uint2', 'int4', 'uint4', 'uint8', 'stringnl',
'string4', 'bytes1', 'bytes4', 'bytes8', 'bytearray8', 'stringnl_noescape', 'stringnl_noescape_pair', 'string1',
'unicodestringnl', 'unicodestring1', 'unicodestring4', 'string4', 'bytes1', 'bytes4', 'bytes8', 'bytearray8',
'unicodestring8', 'decimalnl_short', 'decimalnl_long', 'unicodestringnl', 'unicodestring1', 'unicodestring4',
'floatnl', 'float8', 'long1', 'long4', 'unicodestring8', 'decimalnl_short', 'decimalnl_long',
'StackObject', 'floatnl', 'float8', 'long1', 'long4',
'pyint', 'pylong', 'pyinteger_or_bool', 'pybool', 'pyfloat', 'StackObject',
'pybytes_or_str', 'pystring', 'pybytes', 'pybytearray', 'pyint', 'pylong', 'pyinteger_or_bool', 'pybool', 'pyfloat',
'pyunicode', 'pynone', 'pytuple', 'pylist', 'pydict', 'pybytes_or_str', 'pystring', 'pybytes', 'pybytearray',
'pyset', 'pyfrozenset', 'pybuffer', 'anyobject', 'pyunicode', 'pynone', 'pytuple', 'pylist', 'pydict',
'markobject', 'stackslice', 'OpcodeInfo', 'opcodes', 'pyset', 'pyfrozenset', 'pybuffer', 'anyobject',
'code2op', 'markobject', 'stackslice', 'OpcodeInfo', 'opcodes',
} 'code2op',
support.check__all__(self, pickletools, blacklist=blacklist) }
support.check__all__(self, pickletools, not_exported=not_exported)
def test_main(): def test_main():

View File

@ -672,8 +672,8 @@ class TestKeyedArchive(unittest.TestCase):
class MiscTestCase(unittest.TestCase): class MiscTestCase(unittest.TestCase):
def test__all__(self): def test__all__(self):
blacklist = {"PlistFormat", "PLISTHEADER"} not_exported = {"PlistFormat", "PLISTHEADER"}
support.check__all__(self, plistlib, blacklist=blacklist) support.check__all__(self, plistlib, not_exported=not_exported)
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -1003,12 +1003,11 @@ class SMTPDChannelTestWithEnableSMTPUTF8True(unittest.TestCase):
class MiscTestCase(unittest.TestCase): class MiscTestCase(unittest.TestCase):
def test__all__(self): def test__all__(self):
blacklist = { not_exported = {
"program", "Devnull", "DEBUGSTREAM", "NEWLINE", "COMMASPACE", "program", "Devnull", "DEBUGSTREAM", "NEWLINE", "COMMASPACE",
"DATA_SIZE_DEFAULT", "usage", "Options", "parseargs", "DATA_SIZE_DEFAULT", "usage", "Options", "parseargs",
} }
support.check__all__(self, smtpd, blacklist=blacklist) support.check__all__(self, smtpd, not_exported=not_exported)
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -391,14 +391,14 @@ class TestSupport(unittest.TestCase):
def test_check__all__(self): def test_check__all__(self):
extra = {'tempdir'} extra = {'tempdir'}
blacklist = {'template'} not_exported = {'template'}
support.check__all__(self, support.check__all__(self,
tempfile, tempfile,
extra=extra, extra=extra,
blacklist=blacklist) not_exported=not_exported)
extra = {'TextTestResult', 'installHandler'} extra = {'TextTestResult', 'installHandler'}
blacklist = {'load_tests', "TestProgram", "BaseTestSuite"} not_exported = {'load_tests', "TestProgram", "BaseTestSuite"}
support.check__all__(self, support.check__all__(self,
unittest, unittest,
@ -407,7 +407,7 @@ class TestSupport(unittest.TestCase):
"unittest.main", "unittest.runner", "unittest.main", "unittest.runner",
"unittest.signals", "unittest.async_case"), "unittest.signals", "unittest.async_case"),
extra=extra, extra=extra,
blacklist=blacklist) not_exported=not_exported)
self.assertRaises(AssertionError, support.check__all__, self, unittest) self.assertRaises(AssertionError, support.check__all__, self, unittest)

View File

@ -2257,22 +2257,19 @@ class MiscTest(unittest.TestCase):
tarfile.itn(0x10000000000, 6, tarfile.GNU_FORMAT) tarfile.itn(0x10000000000, 6, tarfile.GNU_FORMAT)
def test__all__(self): def test__all__(self):
blacklist = {'version', 'grp', 'pwd', 'symlink_exception', not_exported = {
'NUL', 'BLOCKSIZE', 'RECORDSIZE', 'GNU_MAGIC', 'version', 'grp', 'pwd', 'symlink_exception', 'NUL', 'BLOCKSIZE',
'POSIX_MAGIC', 'LENGTH_NAME', 'LENGTH_LINK', 'RECORDSIZE', 'GNU_MAGIC', 'POSIX_MAGIC', 'LENGTH_NAME',
'LENGTH_PREFIX', 'REGTYPE', 'AREGTYPE', 'LNKTYPE', 'LENGTH_LINK', 'LENGTH_PREFIX', 'REGTYPE', 'AREGTYPE', 'LNKTYPE',
'SYMTYPE', 'CHRTYPE', 'BLKTYPE', 'DIRTYPE', 'FIFOTYPE', 'SYMTYPE', 'CHRTYPE', 'BLKTYPE', 'DIRTYPE', 'FIFOTYPE', 'CONTTYPE',
'CONTTYPE', 'GNUTYPE_LONGNAME', 'GNUTYPE_LONGLINK', 'GNUTYPE_LONGNAME', 'GNUTYPE_LONGLINK', 'GNUTYPE_SPARSE',
'GNUTYPE_SPARSE', 'XHDTYPE', 'XGLTYPE', 'SOLARIS_XHDTYPE', 'XHDTYPE', 'XGLTYPE', 'SOLARIS_XHDTYPE', 'SUPPORTED_TYPES',
'SUPPORTED_TYPES', 'REGULAR_TYPES', 'GNU_TYPES', 'REGULAR_TYPES', 'GNU_TYPES', 'PAX_FIELDS', 'PAX_NAME_FIELDS',
'PAX_FIELDS', 'PAX_NAME_FIELDS', 'PAX_NUMBER_FIELDS', 'PAX_NUMBER_FIELDS', 'stn', 'nts', 'nti', 'itn', 'calc_chksums',
'stn', 'nts', 'nti', 'itn', 'calc_chksums', 'copyfileobj', 'copyfileobj', 'filemode', 'EmptyHeaderError',
'filemode', 'TruncatedHeaderError', 'EOFHeaderError', 'InvalidHeaderError',
'EmptyHeaderError', 'TruncatedHeaderError', 'SubsequentHeaderError', 'ExFileObject', 'main'}
'EOFHeaderError', 'InvalidHeaderError', support.check__all__(self, tarfile, not_exported=not_exported)
'SubsequentHeaderError', 'ExFileObject',
'main'}
support.check__all__(self, tarfile, blacklist=blacklist)
class CommandLineTest(unittest.TestCase): class CommandLineTest(unittest.TestCase):

View File

@ -1365,9 +1365,9 @@ class BarrierTests(lock_tests.BarrierTests):
class MiscTestCase(unittest.TestCase): class MiscTestCase(unittest.TestCase):
def test__all__(self): def test__all__(self):
extra = {"ThreadError"} extra = {"ThreadError"}
blacklist = {'currentThread', 'activeCount'} not_exported = {'currentThread', 'activeCount'}
support.check__all__(self, threading, ('threading', '_thread'), support.check__all__(self, threading, ('threading', '_thread'),
extra=extra, blacklist=blacklist) extra=extra, not_exported=not_exported)
class InterruptMainTests(unittest.TestCase): class InterruptMainTests(unittest.TestCase):

View File

@ -107,8 +107,7 @@ class WavePCM32Test(WaveTest, unittest.TestCase):
class MiscTestCase(unittest.TestCase): class MiscTestCase(unittest.TestCase):
def test__all__(self): def test__all__(self):
blacklist = {'WAVE_FORMAT_PCM'} support.check__all__(self, wave, not_exported={'WAVE_FORMAT_PCM'})
support.check__all__(self, wave, blacklist=blacklist)
class WaveLowLevelTest(unittest.TestCase): class WaveLowLevelTest(unittest.TestCase):

View File

@ -128,7 +128,7 @@ class ModuleTest(unittest.TestCase):
def test_all(self): def test_all(self):
names = ("xml.etree.ElementTree", "_elementtree") names = ("xml.etree.ElementTree", "_elementtree")
support.check__all__(self, ET, names, blacklist=("HTML_EMPTY",)) support.check__all__(self, ET, names, not_exported=("HTML_EMPTY",))
def serialize(elem, to_string=True, encoding='unicode', **options): def serialize(elem, to_string=True, encoding='unicode', **options):

View File

@ -0,0 +1,2 @@
:mod:`test.support`: Rename ``blacklist`` parameter of
:func:`~test.support.check__all__` to ``not_exported``.