@@ -359,13 +359,19 @@ The :mod:`test.support` module defines the following constants:
359
359
360
360
.. data :: MISSING_C_DOCSTRINGS
361
361
362
- Return ``True `` if running on CPython, not on Windows, and configuration
363
- not set with ``WITH_DOC_STRINGS ``.
362
+ Set to ``True `` if Python is built without docstrings (the
363
+ :c:macro: `WITH_DOC_STRINGS ` macro is not defined).
364
+ See the :option: `configure --without-doc-strings <--without-doc-strings> ` option.
365
+
366
+ See also the :data: `HAVE_DOCSTRINGS ` variable.
364
367
365
368
366
369
.. data :: HAVE_DOCSTRINGS
367
370
368
- Check for presence of docstrings.
371
+ Set to ``True `` if function docstrings are available.
372
+ See the :option: `python -OO <-O> ` option, which strips docstrings of functions implemented in Python.
373
+
374
+ See also the :data: `MISSING_C_DOCSTRINGS ` variable.
369
375
370
376
371
377
.. data :: TEST_HTTP_URL
@@ -423,11 +429,6 @@ The :mod:`test.support` module defines the following functions:
423
429
Used when tests are executed by :mod: `test.regrtest `.
424
430
425
431
426
- .. function :: system_must_validate_cert(f)
427
-
428
- Raise :exc: `unittest.SkipTest ` on TLS certification validation failures.
429
-
430
-
431
432
.. function :: sortdict(dict)
432
433
433
434
Return a repr of *dict * with keys sorted.
@@ -445,12 +446,12 @@ The :mod:`test.support` module defines the following functions:
445
446
446
447
.. function :: match_test(test)
447
448
448
- Match *test * to patterns set in :func: `set_match_tests `.
449
+ Determine whether *test * matches the patterns set in :func: `set_match_tests `.
449
450
450
451
451
- .. function :: set_match_tests(patterns )
452
+ .. function :: set_match_tests(accept_patterns=None, ignore_patterns=None )
452
453
453
- Define match test with regular expression * patterns * .
454
+ Define match patterns on test filenames and test method names for filtering tests .
454
455
455
456
456
457
.. function :: run_unittest(*classes)
@@ -490,7 +491,9 @@ The :mod:`test.support` module defines the following functions:
490
491
.. function :: check_impl_detail(**guards)
491
492
492
493
Use this check to guard CPython's implementation-specific tests or to
493
- run them only on the implementations guarded by the arguments::
494
+ run them only on the implementations guarded by the arguments. This
495
+ function returns ``True `` or ``False `` depending on the host platform.
496
+ Example usage::
494
497
495
498
check_impl_detail() # Only on CPython (default).
496
499
check_impl_detail(jython=True) # Only on Jython.
@@ -509,7 +512,7 @@ The :mod:`test.support` module defines the following functions:
509
512
time the regrtest began.
510
513
511
514
512
- .. function :: get_original_stdout
515
+ .. function :: get_original_stdout()
513
516
514
517
Return the original stdout set by :func: `record_original_stdout ` or
515
518
``sys.stdout `` if it's not set.
@@ -554,7 +557,7 @@ The :mod:`test.support` module defines the following functions:
554
557
555
558
.. function :: disable_faulthandler()
556
559
557
- A context manager that replaces `` sys.stderr `` with `` sys.__stderr__ ` `.
560
+ A context manager that temporary disables :mod: ` faulthandler `.
558
561
559
562
560
563
.. function :: gc_collect()
@@ -567,8 +570,8 @@ The :mod:`test.support` module defines the following functions:
567
570
568
571
.. function :: disable_gc()
569
572
570
- A context manager that disables the garbage collector upon entry and
571
- reenables it upon exit .
573
+ A context manager that disables the garbage collector on entry. On
574
+ exit, the garbage collector is restored to its prior state .
572
575
573
576
574
577
.. function :: swap_attr(obj, attr, new_val)
@@ -633,14 +636,14 @@ The :mod:`test.support` module defines the following functions:
633
636
634
637
.. function :: calcobjsize(fmt)
635
638
636
- Return :func: ` struct.calcsize ` for `` nP{fmt}0n `` or, if `` gettotalrefcount ``
637
- exists, `` 2PnP{ fmt}0P `` .
639
+ Return the size of the :c:type: ` PyObject ` whose structure members are
640
+ defined by * fmt *. The returned value includes the size of the Python object header and alignment .
638
641
639
642
640
643
.. function :: calcvobjsize(fmt)
641
644
642
- Return :func: ` struct.calcsize ` for `` nPn{fmt}0n `` or, if `` gettotalrefcount ``
643
- exists, `` 2PnPn{ fmt}0P `` .
645
+ Return the size of the :c:type: ` PyVarObject ` whose structure members are
646
+ defined by * fmt *. The returned value includes the size of the Python object header and alignment .
644
647
645
648
646
649
.. function :: checksizeof(test, o, size)
@@ -656,6 +659,11 @@ The :mod:`test.support` module defines the following functions:
656
659
have an associated comment identifying the relevant tracker issue.
657
660
658
661
662
+ .. function :: system_must_validate_cert(f)
663
+
664
+ A decorator that skips the decorated test on TLS certification validation failures.
665
+
666
+
659
667
.. decorator :: run_with_locale(catstr, *locales)
660
668
661
669
A decorator for running a function in a different locale, correctly
@@ -673,19 +681,19 @@ The :mod:`test.support` module defines the following functions:
673
681
.. decorator :: requires_freebsd_version(*min_version)
674
682
675
683
Decorator for the minimum version when running test on FreeBSD. If the
676
- FreeBSD version is less than the minimum, raise :exc: ` unittest.SkipTest ` .
684
+ FreeBSD version is less than the minimum, the test is skipped .
677
685
678
686
679
687
.. decorator :: requires_linux_version(*min_version)
680
688
681
689
Decorator for the minimum version when running test on Linux. If the
682
- Linux version is less than the minimum, raise :exc: ` unittest.SkipTest ` .
690
+ Linux version is less than the minimum, the test is skipped .
683
691
684
692
685
693
.. decorator :: requires_mac_version(*min_version)
686
694
687
695
Decorator for the minimum version when running test on macOS. If the
688
- macOS version is less than the minimum, raise :exc: ` unittest.SkipTest ` .
696
+ macOS version is less than the minimum, the test is skipped .
689
697
690
698
691
699
.. decorator :: requires_IEEE_754
@@ -723,7 +731,7 @@ The :mod:`test.support` module defines the following functions:
723
731
Decorator for only running the test if :data: `HAVE_DOCSTRINGS `.
724
732
725
733
726
- .. decorator :: cpython_only(test)
734
+ .. decorator :: cpython_only
727
735
728
736
Decorator for tests only applicable to CPython.
729
737
@@ -734,12 +742,12 @@ The :mod:`test.support` module defines the following functions:
734
742
returns ``False ``, then uses *msg * as the reason for skipping the test.
735
743
736
744
737
- .. decorator :: no_tracing(func)
745
+ .. decorator :: no_tracing
738
746
739
747
Decorator to temporarily turn off tracing for the duration of the test.
740
748
741
749
742
- .. decorator :: refcount_test(test)
750
+ .. decorator :: refcount_test
743
751
744
752
Decorator for tests which involve reference counting. The decorator does
745
753
not run the test if it is not run by CPython. Any trace function is unset
@@ -762,10 +770,9 @@ The :mod:`test.support` module defines the following functions:
762
770
means the test doesn't support dummy runs when ``-M `` is not specified.
763
771
764
772
765
- .. decorator :: bigaddrspacetest(f)
773
+ .. decorator :: bigaddrspacetest
766
774
767
- Decorator for tests that fill the address space. *f * is the function to
768
- wrap.
775
+ Decorator for tests that fill the address space.
769
776
770
777
771
778
.. function :: check_syntax_error(testcase, statement, errtext='', *, lineno=None, offset=None)
@@ -867,7 +874,7 @@ The :mod:`test.support` module defines the following functions:
867
874
868
875
.. function :: check_free_after_iterating(test, iter, cls, args=())
869
876
870
- Assert that * iter * is deallocated after iterating.
877
+ Assert instances of * cls * are deallocated after iterating.
871
878
872
879
873
880
.. function :: missing_compiler_executable(cmd_names=[])
@@ -958,6 +965,16 @@ The :mod:`test.support` module defines the following classes:
958
965
Class to save and restore signal handlers registered by the Python signal
959
966
handler.
960
967
968
+ .. method :: save(self)
969
+
970
+ Save the signal handlers to a dictionary mapping signal numbers to the
971
+ current signal handler.
972
+
973
+ .. method :: restore(self)
974
+
975
+ Set the signal numbers from the :meth: `save ` dictionary to the saved
976
+ handler.
977
+
961
978
962
979
.. class :: Matcher()
963
980
@@ -1101,11 +1118,11 @@ script execution tests.
1101
1118
variables *env_vars * succeeds (``rc == 0 ``) and return a ``(return code,
1102
1119
stdout, stderr) `` tuple.
1103
1120
1104
- If the `` __cleanenv `` keyword is set, *env_vars * is used as a fresh
1121
+ If the * __cleanenv * keyword-only parameter is set, *env_vars * is used as a fresh
1105
1122
environment.
1106
1123
1107
1124
Python is started in isolated mode (command line option ``-I ``),
1108
- except if the `` __isolated `` keyword is set to ``False ``.
1125
+ except if the * __isolated * keyword-only parameter is set to ``False ``.
1109
1126
1110
1127
.. versionchanged :: 3.9
1111
1128
The function no longer strips whitespaces from *stderr *.
@@ -1216,15 +1233,17 @@ The :mod:`test.support.threading_helper` module provides support for threading t
1216
1233
is still alive after *timeout * seconds.
1217
1234
1218
1235
1219
- .. decorator :: reap_threads(func)
1236
+ .. decorator :: reap_threads
1220
1237
1221
1238
Decorator to ensure the threads are cleaned up even if the test fails.
1222
1239
1223
1240
1224
1241
.. function :: start_threads(threads, unlock=None)
1225
1242
1226
- Context manager to start *threads *. It attempts to join the threads upon
1227
- exit.
1243
+ Context manager to start *threads *, which is a sequence of threads.
1244
+ *unlock * is a function called after the threads are started, even if an
1245
+ exception was raised; an example would be :meth: `threading.Event.set `.
1246
+ ``start_threads `` will attempt to join the started threads upon exit.
1228
1247
1229
1248
1230
1249
.. function :: threading_cleanup(*original_values)
@@ -1306,7 +1325,10 @@ The :mod:`test.support.os_helper` module provides support for os tests.
1306
1325
1307
1326
.. data :: TESTFN_NONASCII
1308
1327
1309
- Set to a filename containing the :data: `FS_NONASCII ` character.
1328
+ Set to a filename containing the :data: `FS_NONASCII ` character, if it exists.
1329
+ This guarantees that if the filename exists, it can be encoded and decoded
1330
+ with the default filesystem encoding. This allows tests that require a
1331
+ non-ASCII filename to be easily skipped on platforms where they can't work.
1310
1332
1311
1333
1312
1334
.. data :: TESTFN_UNENCODABLE
@@ -1404,13 +1426,16 @@ The :mod:`test.support.os_helper` module provides support for os tests.
1404
1426
.. function :: rmdir(filename)
1405
1427
1406
1428
Call :func: `os.rmdir ` on *filename *. On Windows platforms, this is
1407
- wrapped with a wait loop that checks for the existence of the file.
1429
+ wrapped with a wait loop that checks for the existence of the file,
1430
+ which is needed due to antivirus programs that can hold files open and prevent
1431
+ deletion.
1408
1432
1409
1433
1410
1434
.. function :: rmtree(path)
1411
1435
1412
1436
Call :func: `shutil.rmtree ` on *path * or call :func: `os.lstat ` and
1413
- :func: `os.rmdir ` to remove a path and its contents. On Windows platforms,
1437
+ :func: `os.rmdir ` to remove a path and its contents. As with :func: `rmdir `,
1438
+ on Windows platforms
1414
1439
this is wrapped with a wait loop that checks for the existence of the files.
1415
1440
1416
1441
@@ -1457,7 +1482,8 @@ The :mod:`test.support.os_helper` module provides support for os tests.
1457
1482
1458
1483
.. function :: unlink(filename)
1459
1484
1460
- Call :func: `os.unlink ` on *filename *. On Windows platforms, this is
1485
+ Call :func: `os.unlink ` on *filename *. As with :func: `rmdir `,
1486
+ on Windows platforms, this is
1461
1487
wrapped with a wait loop that checks for the existence of the file.
1462
1488
1463
1489
@@ -1514,7 +1540,7 @@ The :mod:`test.support.import_helper` module provides support for import tests.
1514
1540
.. versionadded :: 3.1
1515
1541
1516
1542
1517
- .. function :: import_module(name, deprecated=False, *, required_on())
1543
+ .. function :: import_module(name, deprecated=False, *, required_on= ())
1518
1544
1519
1545
This function imports and returns the named module. Unlike a normal
1520
1546
import, this function raises :exc: `unittest.SkipTest ` if the module
@@ -1556,15 +1582,15 @@ The :mod:`test.support.import_helper` module provides support for import tests.
1556
1582
1557
1583
A context manager to force import to return a new module reference. This
1558
1584
is useful for testing module-level behaviors, such as the emission of a
1559
- DeprecationWarning on import. Example usage::
1585
+ :exc: ` DeprecationWarning ` on import. Example usage::
1560
1586
1561
1587
with CleanImport('foo'):
1562
1588
importlib.import_module('foo') # New reference.
1563
1589
1564
1590
1565
1591
.. class :: DirsOnSysPath(*paths)
1566
1592
1567
- A context manager to temporarily add directories to sys.path.
1593
+ A context manager to temporarily add directories to :data: ` sys.path ` .
1568
1594
1569
1595
This makes a copy of :data: `sys.path `, appends any directories given
1570
1596
as positional arguments, then reverts :data: `sys.path ` to the copied
0 commit comments