@@ -368,13 +368,19 @@ The :mod:`test.support` module defines the following constants:
368
368
369
369
.. data :: MISSING_C_DOCSTRINGS
370
370
371
- Return ``True `` if running on CPython, not on Windows, and configuration
372
- not set with ``WITH_DOC_STRINGS ``.
371
+ Set to ``True `` if Python is built without docstrings (the
372
+ :c:macro: `WITH_DOC_STRINGS ` macro is not defined).
373
+ See the :option: `configure --without-doc-strings <--without-doc-strings> ` option.
374
+
375
+ See also the :data: `HAVE_DOCSTRINGS ` variable.
373
376
374
377
375
378
.. data :: HAVE_DOCSTRINGS
376
379
377
- Check for presence of docstrings.
380
+ Set to ``True `` if function docstrings are available.
381
+ See the :option: `python -OO <-O> ` option, which strips docstrings of functions implemented in Python.
382
+
383
+ See also the :data: `MISSING_C_DOCSTRINGS ` variable.
378
384
379
385
380
386
.. data :: TEST_HTTP_URL
@@ -432,11 +438,6 @@ The :mod:`test.support` module defines the following functions:
432
438
Used when tests are executed by :mod: `test.regrtest `.
433
439
434
440
435
- .. function :: system_must_validate_cert(f)
436
-
437
- Raise :exc: `unittest.SkipTest ` on TLS certification validation failures.
438
-
439
-
440
441
.. function :: sortdict(dict)
441
442
442
443
Return a repr of *dict * with keys sorted.
@@ -454,12 +455,12 @@ The :mod:`test.support` module defines the following functions:
454
455
455
456
.. function :: match_test(test)
456
457
457
- Match *test * to patterns set in :func: `set_match_tests `.
458
+ Determine whether *test * matches the patterns set in :func: `set_match_tests `.
458
459
459
460
460
- .. function :: set_match_tests(patterns )
461
+ .. function :: set_match_tests(accept_patterns=None, ignore_patterns=None )
461
462
462
- Define match test with regular expression * patterns * .
463
+ Define match patterns on test filenames and test method names for filtering tests .
463
464
464
465
465
466
.. function :: run_unittest(*classes)
@@ -499,7 +500,9 @@ The :mod:`test.support` module defines the following functions:
499
500
.. function :: check_impl_detail(**guards)
500
501
501
502
Use this check to guard CPython's implementation-specific tests or to
502
- run them only on the implementations guarded by the arguments::
503
+ run them only on the implementations guarded by the arguments. This
504
+ function returns ``True `` or ``False `` depending on the host platform.
505
+ Example usage::
503
506
504
507
check_impl_detail() # Only on CPython (default).
505
508
check_impl_detail(jython=True) # Only on Jython.
@@ -518,7 +521,7 @@ The :mod:`test.support` module defines the following functions:
518
521
time the regrtest began.
519
522
520
523
521
- .. function :: get_original_stdout
524
+ .. function :: get_original_stdout()
522
525
523
526
Return the original stdout set by :func: `record_original_stdout ` or
524
527
``sys.stdout `` if it's not set.
@@ -563,7 +566,7 @@ The :mod:`test.support` module defines the following functions:
563
566
564
567
.. function :: disable_faulthandler()
565
568
566
- A context manager that replaces `` sys.stderr `` with `` sys.__stderr__ ` `.
569
+ A context manager that temporary disables :mod: ` faulthandler `.
567
570
568
571
569
572
.. function :: gc_collect()
@@ -576,8 +579,8 @@ The :mod:`test.support` module defines the following functions:
576
579
577
580
.. function :: disable_gc()
578
581
579
- A context manager that disables the garbage collector upon entry and
580
- reenables it upon exit .
582
+ A context manager that disables the garbage collector on entry. On
583
+ exit, the garbage collector is restored to its prior state .
581
584
582
585
583
586
.. function :: swap_attr(obj, attr, new_val)
@@ -651,14 +654,14 @@ The :mod:`test.support` module defines the following functions:
651
654
652
655
.. function :: calcobjsize(fmt)
653
656
654
- Return :func: ` struct.calcsize ` for `` nP{fmt}0n `` or, if `` gettotalrefcount ``
655
- exists, `` 2PnP{ fmt}0P `` .
657
+ Return the size of the :c:type: ` PyObject ` whose structure members are
658
+ defined by * fmt *. The returned value includes the size of the Python object header and alignment .
656
659
657
660
658
661
.. function :: calcvobjsize(fmt)
659
662
660
- Return :func: ` struct.calcsize ` for `` nPn{fmt}0n `` or, if `` gettotalrefcount ``
661
- exists, `` 2PnPn{ fmt}0P `` .
663
+ Return the size of the :c:type: ` PyVarObject ` whose structure members are
664
+ defined by * fmt *. The returned value includes the size of the Python object header and alignment .
662
665
663
666
664
667
.. function :: checksizeof(test, o, size)
@@ -674,6 +677,11 @@ The :mod:`test.support` module defines the following functions:
674
677
have an associated comment identifying the relevant tracker issue.
675
678
676
679
680
+ .. function :: system_must_validate_cert(f)
681
+
682
+ A decorator that skips the decorated test on TLS certification validation failures.
683
+
684
+
677
685
.. decorator :: run_with_locale(catstr, *locales)
678
686
679
687
A decorator for running a function in a different locale, correctly
@@ -691,19 +699,19 @@ The :mod:`test.support` module defines the following functions:
691
699
.. decorator :: requires_freebsd_version(*min_version)
692
700
693
701
Decorator for the minimum version when running test on FreeBSD. If the
694
- FreeBSD version is less than the minimum, raise :exc: ` unittest.SkipTest ` .
702
+ FreeBSD version is less than the minimum, the test is skipped .
695
703
696
704
697
705
.. decorator :: requires_linux_version(*min_version)
698
706
699
707
Decorator for the minimum version when running test on Linux. If the
700
- Linux version is less than the minimum, raise :exc: ` unittest.SkipTest ` .
708
+ Linux version is less than the minimum, the test is skipped .
701
709
702
710
703
711
.. decorator :: requires_mac_version(*min_version)
704
712
705
713
Decorator for the minimum version when running test on macOS. If the
706
- macOS version is less than the minimum, raise :exc: ` unittest.SkipTest ` .
714
+ macOS version is less than the minimum, the test is skipped .
707
715
708
716
709
717
.. decorator :: requires_IEEE_754
@@ -741,7 +749,7 @@ The :mod:`test.support` module defines the following functions:
741
749
Decorator for only running the test if :data: `HAVE_DOCSTRINGS `.
742
750
743
751
744
- .. decorator :: cpython_only(test)
752
+ .. decorator :: cpython_only
745
753
746
754
Decorator for tests only applicable to CPython.
747
755
@@ -752,12 +760,12 @@ The :mod:`test.support` module defines the following functions:
752
760
returns ``False ``, then uses *msg * as the reason for skipping the test.
753
761
754
762
755
- .. decorator :: no_tracing(func)
763
+ .. decorator :: no_tracing
756
764
757
765
Decorator to temporarily turn off tracing for the duration of the test.
758
766
759
767
760
- .. decorator :: refcount_test(test)
768
+ .. decorator :: refcount_test
761
769
762
770
Decorator for tests which involve reference counting. The decorator does
763
771
not run the test if it is not run by CPython. Any trace function is unset
@@ -780,10 +788,9 @@ The :mod:`test.support` module defines the following functions:
780
788
means the test doesn't support dummy runs when ``-M `` is not specified.
781
789
782
790
783
- .. decorator :: bigaddrspacetest(f)
791
+ .. decorator :: bigaddrspacetest
784
792
785
- Decorator for tests that fill the address space. *f * is the function to
786
- wrap.
793
+ Decorator for tests that fill the address space.
787
794
788
795
789
796
.. function :: check_syntax_error(testcase, statement, errtext='', *, lineno=None, offset=None)
@@ -885,7 +892,7 @@ The :mod:`test.support` module defines the following functions:
885
892
886
893
.. function :: check_free_after_iterating(test, iter, cls, args=())
887
894
888
- Assert that * iter * is deallocated after iterating.
895
+ Assert instances of * cls * are deallocated after iterating.
889
896
890
897
891
898
.. function :: missing_compiler_executable(cmd_names=[])
@@ -976,6 +983,16 @@ The :mod:`test.support` module defines the following classes:
976
983
Class to save and restore signal handlers registered by the Python signal
977
984
handler.
978
985
986
+ .. method :: save(self)
987
+
988
+ Save the signal handlers to a dictionary mapping signal numbers to the
989
+ current signal handler.
990
+
991
+ .. method :: restore(self)
992
+
993
+ Set the signal numbers from the :meth: `save ` dictionary to the saved
994
+ handler.
995
+
979
996
980
997
.. class :: Matcher()
981
998
@@ -1112,11 +1129,11 @@ script execution tests.
1112
1129
variables *env_vars * succeeds (``rc == 0 ``) and return a ``(return code,
1113
1130
stdout, stderr) `` tuple.
1114
1131
1115
- If the `` __cleanenv `` keyword is set, *env_vars * is used as a fresh
1132
+ If the * __cleanenv * keyword-only parameter is set, *env_vars * is used as a fresh
1116
1133
environment.
1117
1134
1118
1135
Python is started in isolated mode (command line option ``-I ``),
1119
- except if the `` __isolated `` keyword is set to ``False ``.
1136
+ except if the * __isolated * keyword-only parameter is set to ``False ``.
1120
1137
1121
1138
.. versionchanged :: 3.9
1122
1139
The function no longer strips whitespaces from *stderr *.
@@ -1227,15 +1244,17 @@ The :mod:`test.support.threading_helper` module provides support for threading t
1227
1244
is still alive after *timeout * seconds.
1228
1245
1229
1246
1230
- .. decorator :: reap_threads(func)
1247
+ .. decorator :: reap_threads
1231
1248
1232
1249
Decorator to ensure the threads are cleaned up even if the test fails.
1233
1250
1234
1251
1235
1252
.. function :: start_threads(threads, unlock=None)
1236
1253
1237
- Context manager to start *threads *. It attempts to join the threads upon
1238
- exit.
1254
+ Context manager to start *threads *, which is a sequence of threads.
1255
+ *unlock * is a function called after the threads are started, even if an
1256
+ exception was raised; an example would be :meth: `threading.Event.set `.
1257
+ ``start_threads `` will attempt to join the started threads upon exit.
1239
1258
1240
1259
1241
1260
.. function :: threading_cleanup(*original_values)
@@ -1317,7 +1336,10 @@ The :mod:`test.support.os_helper` module provides support for os tests.
1317
1336
1318
1337
.. data :: TESTFN_NONASCII
1319
1338
1320
- Set to a filename containing the :data: `FS_NONASCII ` character.
1339
+ Set to a filename containing the :data: `FS_NONASCII ` character, if it exists.
1340
+ This guarantees that if the filename exists, it can be encoded and decoded
1341
+ with the default filesystem encoding. This allows tests that require a
1342
+ non-ASCII filename to be easily skipped on platforms where they can't work.
1321
1343
1322
1344
1323
1345
.. data :: TESTFN_UNENCODABLE
@@ -1415,13 +1437,16 @@ The :mod:`test.support.os_helper` module provides support for os tests.
1415
1437
.. function :: rmdir(filename)
1416
1438
1417
1439
Call :func: `os.rmdir ` on *filename *. On Windows platforms, this is
1418
- wrapped with a wait loop that checks for the existence of the file.
1440
+ wrapped with a wait loop that checks for the existence of the file,
1441
+ which is needed due to antivirus programs that can hold files open and prevent
1442
+ deletion.
1419
1443
1420
1444
1421
1445
.. function :: rmtree(path)
1422
1446
1423
1447
Call :func: `shutil.rmtree ` on *path * or call :func: `os.lstat ` and
1424
- :func: `os.rmdir ` to remove a path and its contents. On Windows platforms,
1448
+ :func: `os.rmdir ` to remove a path and its contents. As with :func: `rmdir `,
1449
+ on Windows platforms
1425
1450
this is wrapped with a wait loop that checks for the existence of the files.
1426
1451
1427
1452
@@ -1468,7 +1493,8 @@ The :mod:`test.support.os_helper` module provides support for os tests.
1468
1493
1469
1494
.. function :: unlink(filename)
1470
1495
1471
- Call :func: `os.unlink ` on *filename *. On Windows platforms, this is
1496
+ Call :func: `os.unlink ` on *filename *. As with :func: `rmdir `,
1497
+ on Windows platforms, this is
1472
1498
wrapped with a wait loop that checks for the existence of the file.
1473
1499
1474
1500
@@ -1525,7 +1551,7 @@ The :mod:`test.support.import_helper` module provides support for import tests.
1525
1551
.. versionadded :: 3.1
1526
1552
1527
1553
1528
- .. function :: import_module(name, deprecated=False, *, required_on())
1554
+ .. function :: import_module(name, deprecated=False, *, required_on= ())
1529
1555
1530
1556
This function imports and returns the named module. Unlike a normal
1531
1557
import, this function raises :exc: `unittest.SkipTest ` if the module
@@ -1567,15 +1593,15 @@ The :mod:`test.support.import_helper` module provides support for import tests.
1567
1593
1568
1594
A context manager to force import to return a new module reference. This
1569
1595
is useful for testing module-level behaviors, such as the emission of a
1570
- DeprecationWarning on import. Example usage::
1596
+ :exc: ` DeprecationWarning ` on import. Example usage::
1571
1597
1572
1598
with CleanImport('foo'):
1573
1599
importlib.import_module('foo') # New reference.
1574
1600
1575
1601
1576
1602
.. class :: DirsOnSysPath(*paths)
1577
1603
1578
- A context manager to temporarily add directories to sys.path.
1604
+ A context manager to temporarily add directories to :data: ` sys.path ` .
1579
1605
1580
1606
This makes a copy of :data: `sys.path `, appends any directories given
1581
1607
as positional arguments, then reverts :data: `sys.path ` to the copied
0 commit comments