Skip to content

Commit fbf43f0

Browse files
authored
bpo-41521: Rename blacklist parameter to not_exported (GH-21824)
Rename "blacklist" parameter of test.support.check__all__() to "not_exported".
1 parent 9700346 commit fbf43f0

20 files changed

+98
-97
lines changed

Doc/library/test.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ The :mod:`test.support` module defines the following functions:
878878
missing.
879879

880880

881-
.. function:: check__all__(test_case, module, name_of_module=None, extra=(), blacklist=())
881+
.. function:: check__all__(test_case, module, name_of_module=None, extra=(), not_exported=())
882882

883883
Assert that the ``__all__`` variable of *module* contains all public names.
884884

@@ -895,8 +895,8 @@ The :mod:`test.support` module defines the following functions:
895895
detected as "public", like objects without a proper ``__module__``
896896
attribute. If provided, it will be added to the automatically detected ones.
897897

898-
The *blacklist* argument can be a set of names that must not be treated as part of
899-
the public API even though their names indicate otherwise.
898+
The *not_exported* argument can be a set of names that must not be treated
899+
as part of the public API even though their names indicate otherwise.
900900

901901
Example use::
902902

@@ -912,10 +912,10 @@ The :mod:`test.support` module defines the following functions:
912912
class OtherTestCase(unittest.TestCase):
913913
def test__all__(self):
914914
extra = {'BAR_CONST', 'FOO_CONST'}
915-
blacklist = {'baz'} # Undocumented name.
915+
not_exported = {'baz'} # Undocumented name.
916916
# bar imports part of its API from _bar.
917917
support.check__all__(self, bar, ('bar', '_bar'),
918-
extra=extra, blacklist=blacklist)
918+
extra=extra, not_exported=not_exported)
919919

920920
.. versionadded:: 3.6
921921

Lib/test/_test_multiprocessing.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5581,9 +5581,11 @@ def test_namespace(self):
55815581

55825582
class MiscTestCase(unittest.TestCase):
55835583
def test__all__(self):
5584-
# Just make sure names in blacklist are excluded
5584+
# Just make sure names in not_exported are excluded
55855585
support.check__all__(self, multiprocessing, extra=multiprocessing.__all__,
5586-
blacklist=['SUBDEBUG', 'SUBWARNING'])
5586+
not_exported=['SUBDEBUG', 'SUBWARNING'])
5587+
5588+
55875589
#
55885590
# Mixins
55895591
#

Lib/test/support/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,7 +1410,7 @@ def detect_api_mismatch(ref_api, other_api, *, ignore=()):
14101410

14111411

14121412
def check__all__(test_case, module, name_of_module=None, extra=(),
1413-
blacklist=()):
1413+
not_exported=()):
14141414
"""Assert that the __all__ variable of 'module' contains all public names.
14151415
14161416
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=(),
14271427
'__module__' attribute. If provided, it will be added to the
14281428
automatically detected ones.
14291429
1430-
The 'blacklist' argument can be a set of names that must not be treated
1430+
The 'not_exported' argument can be a set of names that must not be treated
14311431
as part of the public API even though their names indicate otherwise.
14321432
14331433
Usage:
@@ -1443,10 +1443,10 @@ def test__all__(self):
14431443
class OtherTestCase(unittest.TestCase):
14441444
def test__all__(self):
14451445
extra = {'BAR_CONST', 'FOO_CONST'}
1446-
blacklist = {'baz'} # Undocumented name.
1446+
not_exported = {'baz'} # Undocumented name.
14471447
# bar imports part of its API from _bar.
14481448
support.check__all__(self, bar, ('bar', '_bar'),
1449-
extra=extra, blacklist=blacklist)
1449+
extra=extra, not_exported=not_exported)
14501450
14511451
"""
14521452

@@ -1458,7 +1458,7 @@ def test__all__(self):
14581458
expected = set(extra)
14591459

14601460
for name in dir(module):
1461-
if name.startswith('_') or name in blacklist:
1461+
if name.startswith('_') or name in not_exported:
14621462
continue
14631463
obj = getattr(module, name)
14641464
if (getattr(obj, '__module__', None) in name_of_module or

Lib/test/test_calendar.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -934,12 +934,12 @@ def test_html_output_year_css(self):
934934

935935
class MiscTestCase(unittest.TestCase):
936936
def test__all__(self):
937-
blacklist = {'mdays', 'January', 'February', 'EPOCH',
938-
'MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY',
939-
'SATURDAY', 'SUNDAY', 'different_locale', 'c',
940-
'prweek', 'week', 'format', 'formatstring', 'main',
941-
'monthlen', 'prevmonth', 'nextmonth'}
942-
support.check__all__(self, calendar, blacklist=blacklist)
937+
not_exported = {
938+
'mdays', 'January', 'February', 'EPOCH', 'MONDAY', 'TUESDAY',
939+
'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY', 'SUNDAY',
940+
'different_locale', 'c', 'prweek', 'week', 'format',
941+
'formatstring', 'main', 'monthlen', 'prevmonth', 'nextmonth'}
942+
support.check__all__(self, calendar, not_exported=not_exported)
943943

944944

945945
class TestSubClassingCase(unittest.TestCase):

Lib/test/test_cgi.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,9 +553,10 @@ def test_parse_header(self):
553553
("form-data", {"name": "files", "filename": 'fo"o;bar'}))
554554

555555
def test_all(self):
556-
blacklist = {"logfile", "logfp", "initlog", "dolog", "nolog",
557-
"closelog", "log", "maxlen", "valid_boundary"}
558-
support.check__all__(self, cgi, blacklist=blacklist)
556+
not_exported = {
557+
"logfile", "logfp", "initlog", "dolog", "nolog", "closelog", "log",
558+
"maxlen", "valid_boundary"}
559+
support.check__all__(self, cgi, not_exported=not_exported)
559560

560561

561562
BOUNDARY = "---------------------------721837373350705526688164684"

Lib/test/test_configparser.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2128,8 +2128,7 @@ def test_instance_assignment(self):
21282128

21292129
class MiscTestCase(unittest.TestCase):
21302130
def test__all__(self):
2131-
blacklist = {"Error"}
2132-
support.check__all__(self, configparser, blacklist=blacklist)
2131+
support.check__all__(self, configparser, not_exported={"Error"})
21332132

21342133

21352134
if __name__ == '__main__':

Lib/test/test_ftplib.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,10 +1107,11 @@ def testTimeoutDirectAccess(self):
11071107

11081108
class MiscTestCase(TestCase):
11091109
def test__all__(self):
1110-
blacklist = {'MSG_OOB', 'FTP_PORT', 'MAXLINE', 'CRLF', 'B_CRLF',
1111-
'Error', 'parse150', 'parse227', 'parse229', 'parse257',
1112-
'print_line', 'ftpcp', 'test'}
1113-
support.check__all__(self, ftplib, blacklist=blacklist)
1110+
not_exported = {
1111+
'MSG_OOB', 'FTP_PORT', 'MAXLINE', 'CRLF', 'B_CRLF', 'Error',
1112+
'parse150', 'parse227', 'parse229', 'parse257', 'print_line',
1113+
'ftpcp', 'test'}
1114+
support.check__all__(self, ftplib, not_exported=not_exported)
11141115

11151116

11161117
def test_main():

Lib/test/test_gettext.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,8 +820,8 @@ def test_cache(self):
820820

821821
class MiscTestCase(unittest.TestCase):
822822
def test__all__(self):
823-
blacklist = {'c2py', 'ENOENT'}
824-
support.check__all__(self, gettext, blacklist=blacklist)
823+
support.check__all__(self, gettext,
824+
not_exported={'c2py', 'ENOENT'})
825825

826826

827827
if __name__ == '__main__':

Lib/test/test_logging.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5363,12 +5363,12 @@ def test_basic(self):
53635363

53645364
class MiscTestCase(unittest.TestCase):
53655365
def test__all__(self):
5366-
blacklist = {'logThreads', 'logMultiprocessing',
5367-
'logProcesses', 'currentframe',
5368-
'PercentStyle', 'StrFormatStyle', 'StringTemplateStyle',
5369-
'Filterer', 'PlaceHolder', 'Manager', 'RootLogger',
5370-
'root', 'threading'}
5371-
support.check__all__(self, logging, blacklist=blacklist)
5366+
not_exported = {
5367+
'logThreads', 'logMultiprocessing', 'logProcesses', 'currentframe',
5368+
'PercentStyle', 'StrFormatStyle', 'StringTemplateStyle',
5369+
'Filterer', 'PlaceHolder', 'Manager', 'RootLogger', 'root',
5370+
'threading'}
5371+
support.check__all__(self, logging, not_exported=not_exported)
53725372

53735373

53745374
# Set the locale to the platform-dependent default. I have no idea

Lib/test/test_mailbox.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2296,8 +2296,8 @@ def test_nonempty_maildir_both(self):
22962296

22972297
class MiscTestCase(unittest.TestCase):
22982298
def test__all__(self):
2299-
blacklist = {"linesep", "fcntl"}
2300-
support.check__all__(self, mailbox, blacklist=blacklist)
2299+
support.check__all__(self, mailbox,
2300+
not_exported={"linesep", "fcntl"})
23012301

23022302

23032303
def test_main():

Lib/test/test_optparse.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,8 +1652,8 @@ def test_numeric_options(self):
16521652

16531653
class MiscTestCase(unittest.TestCase):
16541654
def test__all__(self):
1655-
blacklist = {'check_builtin', 'AmbiguousOptionError', 'NO_DEFAULT'}
1656-
support.check__all__(self, optparse, blacklist=blacklist)
1655+
not_exported = {'check_builtin', 'AmbiguousOptionError', 'NO_DEFAULT'}
1656+
support.check__all__(self, optparse, not_exported=not_exported)
16571657

16581658

16591659
def test_main():

Lib/test/test_pickletools.py

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -63,34 +63,35 @@ def test_optimize_binput_and_memoize(self):
6363

6464
class MiscTestCase(unittest.TestCase):
6565
def test__all__(self):
66-
blacklist = {'bytes_types',
67-
'UP_TO_NEWLINE', 'TAKEN_FROM_ARGUMENT1',
68-
'TAKEN_FROM_ARGUMENT4', 'TAKEN_FROM_ARGUMENT4U',
69-
'TAKEN_FROM_ARGUMENT8U', 'ArgumentDescriptor',
70-
'read_uint1', 'read_uint2', 'read_int4', 'read_uint4',
71-
'read_uint8', 'read_stringnl', 'read_stringnl_noescape',
72-
'read_stringnl_noescape_pair', 'read_string1',
73-
'read_string4', 'read_bytes1', 'read_bytes4',
74-
'read_bytes8', 'read_bytearray8', 'read_unicodestringnl',
75-
'read_unicodestring1', 'read_unicodestring4',
76-
'read_unicodestring8', 'read_decimalnl_short',
77-
'read_decimalnl_long', 'read_floatnl', 'read_float8',
78-
'read_long1', 'read_long4',
79-
'uint1', 'uint2', 'int4', 'uint4', 'uint8', 'stringnl',
80-
'stringnl_noescape', 'stringnl_noescape_pair', 'string1',
81-
'string4', 'bytes1', 'bytes4', 'bytes8', 'bytearray8',
82-
'unicodestringnl', 'unicodestring1', 'unicodestring4',
83-
'unicodestring8', 'decimalnl_short', 'decimalnl_long',
84-
'floatnl', 'float8', 'long1', 'long4',
85-
'StackObject',
86-
'pyint', 'pylong', 'pyinteger_or_bool', 'pybool', 'pyfloat',
87-
'pybytes_or_str', 'pystring', 'pybytes', 'pybytearray',
88-
'pyunicode', 'pynone', 'pytuple', 'pylist', 'pydict',
89-
'pyset', 'pyfrozenset', 'pybuffer', 'anyobject',
90-
'markobject', 'stackslice', 'OpcodeInfo', 'opcodes',
91-
'code2op',
92-
}
93-
support.check__all__(self, pickletools, blacklist=blacklist)
66+
not_exported = {
67+
'bytes_types',
68+
'UP_TO_NEWLINE', 'TAKEN_FROM_ARGUMENT1',
69+
'TAKEN_FROM_ARGUMENT4', 'TAKEN_FROM_ARGUMENT4U',
70+
'TAKEN_FROM_ARGUMENT8U', 'ArgumentDescriptor',
71+
'read_uint1', 'read_uint2', 'read_int4', 'read_uint4',
72+
'read_uint8', 'read_stringnl', 'read_stringnl_noescape',
73+
'read_stringnl_noescape_pair', 'read_string1',
74+
'read_string4', 'read_bytes1', 'read_bytes4',
75+
'read_bytes8', 'read_bytearray8', 'read_unicodestringnl',
76+
'read_unicodestring1', 'read_unicodestring4',
77+
'read_unicodestring8', 'read_decimalnl_short',
78+
'read_decimalnl_long', 'read_floatnl', 'read_float8',
79+
'read_long1', 'read_long4',
80+
'uint1', 'uint2', 'int4', 'uint4', 'uint8', 'stringnl',
81+
'stringnl_noescape', 'stringnl_noescape_pair', 'string1',
82+
'string4', 'bytes1', 'bytes4', 'bytes8', 'bytearray8',
83+
'unicodestringnl', 'unicodestring1', 'unicodestring4',
84+
'unicodestring8', 'decimalnl_short', 'decimalnl_long',
85+
'floatnl', 'float8', 'long1', 'long4',
86+
'StackObject',
87+
'pyint', 'pylong', 'pyinteger_or_bool', 'pybool', 'pyfloat',
88+
'pybytes_or_str', 'pystring', 'pybytes', 'pybytearray',
89+
'pyunicode', 'pynone', 'pytuple', 'pylist', 'pydict',
90+
'pyset', 'pyfrozenset', 'pybuffer', 'anyobject',
91+
'markobject', 'stackslice', 'OpcodeInfo', 'opcodes',
92+
'code2op',
93+
}
94+
support.check__all__(self, pickletools, not_exported=not_exported)
9495

9596

9697
def test_main():

Lib/test/test_plistlib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,8 +672,8 @@ def test_keyed_archive_data(self):
672672

673673
class MiscTestCase(unittest.TestCase):
674674
def test__all__(self):
675-
blacklist = {"PlistFormat", "PLISTHEADER"}
676-
support.check__all__(self, plistlib, blacklist=blacklist)
675+
not_exported = {"PlistFormat", "PLISTHEADER"}
676+
support.check__all__(self, plistlib, not_exported=not_exported)
677677

678678

679679
if __name__ == '__main__':

Lib/test/test_smtpd.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,12 +1003,11 @@ def test_multiple_emails_with_extended_command_length(self):
10031003

10041004
class MiscTestCase(unittest.TestCase):
10051005
def test__all__(self):
1006-
blacklist = {
1006+
not_exported = {
10071007
"program", "Devnull", "DEBUGSTREAM", "NEWLINE", "COMMASPACE",
10081008
"DATA_SIZE_DEFAULT", "usage", "Options", "parseargs",
1009-
10101009
}
1011-
support.check__all__(self, smtpd, blacklist=blacklist)
1010+
support.check__all__(self, smtpd, not_exported=not_exported)
10121011

10131012

10141013
if __name__ == "__main__":

Lib/test/test_support.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,14 +391,14 @@ def test_detect_api_mismatch__ignore(self):
391391

392392
def test_check__all__(self):
393393
extra = {'tempdir'}
394-
blacklist = {'template'}
394+
not_exported = {'template'}
395395
support.check__all__(self,
396396
tempfile,
397397
extra=extra,
398-
blacklist=blacklist)
398+
not_exported=not_exported)
399399

400400
extra = {'TextTestResult', 'installHandler'}
401-
blacklist = {'load_tests', "TestProgram", "BaseTestSuite"}
401+
not_exported = {'load_tests', "TestProgram", "BaseTestSuite"}
402402

403403
support.check__all__(self,
404404
unittest,
@@ -407,7 +407,7 @@ def test_check__all__(self):
407407
"unittest.main", "unittest.runner",
408408
"unittest.signals", "unittest.async_case"),
409409
extra=extra,
410-
blacklist=blacklist)
410+
not_exported=not_exported)
411411

412412
self.assertRaises(AssertionError, support.check__all__, self, unittest)
413413

Lib/test/test_tarfile.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,22 +2257,19 @@ def test_number_field_limits(self):
22572257
tarfile.itn(0x10000000000, 6, tarfile.GNU_FORMAT)
22582258

22592259
def test__all__(self):
2260-
blacklist = {'version', 'grp', 'pwd', 'symlink_exception',
2261-
'NUL', 'BLOCKSIZE', 'RECORDSIZE', 'GNU_MAGIC',
2262-
'POSIX_MAGIC', 'LENGTH_NAME', 'LENGTH_LINK',
2263-
'LENGTH_PREFIX', 'REGTYPE', 'AREGTYPE', 'LNKTYPE',
2264-
'SYMTYPE', 'CHRTYPE', 'BLKTYPE', 'DIRTYPE', 'FIFOTYPE',
2265-
'CONTTYPE', 'GNUTYPE_LONGNAME', 'GNUTYPE_LONGLINK',
2266-
'GNUTYPE_SPARSE', 'XHDTYPE', 'XGLTYPE', 'SOLARIS_XHDTYPE',
2267-
'SUPPORTED_TYPES', 'REGULAR_TYPES', 'GNU_TYPES',
2268-
'PAX_FIELDS', 'PAX_NAME_FIELDS', 'PAX_NUMBER_FIELDS',
2269-
'stn', 'nts', 'nti', 'itn', 'calc_chksums', 'copyfileobj',
2270-
'filemode',
2271-
'EmptyHeaderError', 'TruncatedHeaderError',
2272-
'EOFHeaderError', 'InvalidHeaderError',
2273-
'SubsequentHeaderError', 'ExFileObject',
2274-
'main'}
2275-
support.check__all__(self, tarfile, blacklist=blacklist)
2260+
not_exported = {
2261+
'version', 'grp', 'pwd', 'symlink_exception', 'NUL', 'BLOCKSIZE',
2262+
'RECORDSIZE', 'GNU_MAGIC', 'POSIX_MAGIC', 'LENGTH_NAME',
2263+
'LENGTH_LINK', 'LENGTH_PREFIX', 'REGTYPE', 'AREGTYPE', 'LNKTYPE',
2264+
'SYMTYPE', 'CHRTYPE', 'BLKTYPE', 'DIRTYPE', 'FIFOTYPE', 'CONTTYPE',
2265+
'GNUTYPE_LONGNAME', 'GNUTYPE_LONGLINK', 'GNUTYPE_SPARSE',
2266+
'XHDTYPE', 'XGLTYPE', 'SOLARIS_XHDTYPE', 'SUPPORTED_TYPES',
2267+
'REGULAR_TYPES', 'GNU_TYPES', 'PAX_FIELDS', 'PAX_NAME_FIELDS',
2268+
'PAX_NUMBER_FIELDS', 'stn', 'nts', 'nti', 'itn', 'calc_chksums',
2269+
'copyfileobj', 'filemode', 'EmptyHeaderError',
2270+
'TruncatedHeaderError', 'EOFHeaderError', 'InvalidHeaderError',
2271+
'SubsequentHeaderError', 'ExFileObject', 'main'}
2272+
support.check__all__(self, tarfile, not_exported=not_exported)
22762273

22772274

22782275
class CommandLineTest(unittest.TestCase):

Lib/test/test_threading.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,9 +1365,9 @@ class BarrierTests(lock_tests.BarrierTests):
13651365
class MiscTestCase(unittest.TestCase):
13661366
def test__all__(self):
13671367
extra = {"ThreadError"}
1368-
blacklist = {'currentThread', 'activeCount'}
1368+
not_exported = {'currentThread', 'activeCount'}
13691369
support.check__all__(self, threading, ('threading', '_thread'),
1370-
extra=extra, blacklist=blacklist)
1370+
extra=extra, not_exported=not_exported)
13711371

13721372

13731373
class InterruptMainTests(unittest.TestCase):

Lib/test/test_wave.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ class WavePCM32Test(WaveTest, unittest.TestCase):
107107

108108
class MiscTestCase(unittest.TestCase):
109109
def test__all__(self):
110-
blacklist = {'WAVE_FORMAT_PCM'}
111-
support.check__all__(self, wave, blacklist=blacklist)
110+
support.check__all__(self, wave, not_exported={'WAVE_FORMAT_PCM'})
112111

113112

114113
class WaveLowLevelTest(unittest.TestCase):

Lib/test/test_xml_etree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def test_sanity(self):
128128

129129
def test_all(self):
130130
names = ("xml.etree.ElementTree", "_elementtree")
131-
support.check__all__(self, ET, names, blacklist=("HTML_EMPTY",))
131+
support.check__all__(self, ET, names, not_exported=("HTML_EMPTY",))
132132

133133

134134
def serialize(elem, to_string=True, encoding='unicode', **options):
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
:mod:`test.support`: Rename ``blacklist`` parameter of
2+
:func:`~test.support.check__all__` to ``not_exported``.

0 commit comments

Comments
 (0)