@@ -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)
@@ -642,14 +645,14 @@ The :mod:`test.support` module defines the following functions:
642
645
643
646
.. function :: calcobjsize(fmt)
644
647
645
- Return :func: ` struct.calcsize ` for `` nP{fmt}0n `` or, if `` gettotalrefcount ``
646
- exists, `` 2PnP{ fmt}0P `` .
648
+ Return the size of the :c:type: ` PyObject ` whose structure members are
649
+ defined by * fmt *. The returned value includes the size of the Python object header and alignment .
647
650
648
651
649
652
.. function :: calcvobjsize(fmt)
650
653
651
- Return :func: ` struct.calcsize ` for `` nPn{fmt}0n `` or, if `` gettotalrefcount ``
652
- exists, `` 2PnPn{ fmt}0P `` .
654
+ Return the size of the :c:type: ` PyVarObject ` whose structure members are
655
+ defined by * fmt *. The returned value includes the size of the Python object header and alignment .
653
656
654
657
655
658
.. function :: checksizeof(test, o, size)
@@ -665,6 +668,11 @@ The :mod:`test.support` module defines the following functions:
665
668
have an associated comment identifying the relevant tracker issue.
666
669
667
670
671
+ .. function :: system_must_validate_cert(f)
672
+
673
+ A decorator that skips the decorated test on TLS certification validation failures.
674
+
675
+
668
676
.. decorator :: run_with_locale(catstr, *locales)
669
677
670
678
A decorator for running a function in a different locale, correctly
@@ -682,19 +690,19 @@ The :mod:`test.support` module defines the following functions:
682
690
.. decorator :: requires_freebsd_version(*min_version)
683
691
684
692
Decorator for the minimum version when running test on FreeBSD. If the
685
- FreeBSD version is less than the minimum, raise :exc: ` unittest.SkipTest ` .
693
+ FreeBSD version is less than the minimum, the test is skipped .
686
694
687
695
688
696
.. decorator :: requires_linux_version(*min_version)
689
697
690
698
Decorator for the minimum version when running test on Linux. If the
691
- Linux version is less than the minimum, raise :exc: ` unittest.SkipTest ` .
699
+ Linux version is less than the minimum, the test is skipped .
692
700
693
701
694
702
.. decorator :: requires_mac_version(*min_version)
695
703
696
704
Decorator for the minimum version when running test on macOS. If the
697
- macOS version is less than the minimum, raise :exc: ` unittest.SkipTest ` .
705
+ macOS version is less than the minimum, the test is skipped .
698
706
699
707
700
708
.. decorator :: requires_IEEE_754
@@ -732,7 +740,7 @@ The :mod:`test.support` module defines the following functions:
732
740
Decorator for only running the test if :data: `HAVE_DOCSTRINGS `.
733
741
734
742
735
- .. decorator :: cpython_only(test)
743
+ .. decorator :: cpython_only
736
744
737
745
Decorator for tests only applicable to CPython.
738
746
@@ -743,12 +751,12 @@ The :mod:`test.support` module defines the following functions:
743
751
returns ``False ``, then uses *msg * as the reason for skipping the test.
744
752
745
753
746
- .. decorator :: no_tracing(func)
754
+ .. decorator :: no_tracing
747
755
748
756
Decorator to temporarily turn off tracing for the duration of the test.
749
757
750
758
751
- .. decorator :: refcount_test(test)
759
+ .. decorator :: refcount_test
752
760
753
761
Decorator for tests which involve reference counting. The decorator does
754
762
not run the test if it is not run by CPython. Any trace function is unset
@@ -771,10 +779,9 @@ The :mod:`test.support` module defines the following functions:
771
779
means the test doesn't support dummy runs when ``-M `` is not specified.
772
780
773
781
774
- .. decorator :: bigaddrspacetest(f)
782
+ .. decorator :: bigaddrspacetest
775
783
776
- Decorator for tests that fill the address space. *f * is the function to
777
- wrap.
784
+ Decorator for tests that fill the address space.
778
785
779
786
780
787
.. function :: check_syntax_error(testcase, statement, errtext='', *, lineno=None, offset=None)
@@ -876,7 +883,7 @@ The :mod:`test.support` module defines the following functions:
876
883
877
884
.. function :: check_free_after_iterating(test, iter, cls, args=())
878
885
879
- Assert that * iter * is deallocated after iterating.
886
+ Assert instances of * cls * are deallocated after iterating.
880
887
881
888
882
889
.. function :: missing_compiler_executable(cmd_names=[])
@@ -967,6 +974,16 @@ The :mod:`test.support` module defines the following classes:
967
974
Class to save and restore signal handlers registered by the Python signal
968
975
handler.
969
976
977
+ .. method :: save(self)
978
+
979
+ Save the signal handlers to a dictionary mapping signal numbers to the
980
+ current signal handler.
981
+
982
+ .. method :: restore(self)
983
+
984
+ Set the signal numbers from the :meth: `save ` dictionary to the saved
985
+ handler.
986
+
970
987
971
988
.. class :: Matcher()
972
989
@@ -1110,11 +1127,11 @@ script execution tests.
1110
1127
variables *env_vars * succeeds (``rc == 0 ``) and return a ``(return code,
1111
1128
stdout, stderr) `` tuple.
1112
1129
1113
- If the `` __cleanenv `` keyword is set, *env_vars * is used as a fresh
1130
+ If the * __cleanenv * keyword-only parameter is set, *env_vars * is used as a fresh
1114
1131
environment.
1115
1132
1116
1133
Python is started in isolated mode (command line option ``-I ``),
1117
- except if the `` __isolated `` keyword is set to ``False ``.
1134
+ except if the * __isolated * keyword-only parameter is set to ``False ``.
1118
1135
1119
1136
.. versionchanged :: 3.9
1120
1137
The function no longer strips whitespaces from *stderr *.
@@ -1225,15 +1242,17 @@ The :mod:`test.support.threading_helper` module provides support for threading t
1225
1242
is still alive after *timeout * seconds.
1226
1243
1227
1244
1228
- .. decorator :: reap_threads(func)
1245
+ .. decorator :: reap_threads
1229
1246
1230
1247
Decorator to ensure the threads are cleaned up even if the test fails.
1231
1248
1232
1249
1233
1250
.. function :: start_threads(threads, unlock=None)
1234
1251
1235
- Context manager to start *threads *. It attempts to join the threads upon
1236
- exit.
1252
+ Context manager to start *threads *, which is a sequence of threads.
1253
+ *unlock * is a function called after the threads are started, even if an
1254
+ exception was raised; an example would be :meth: `threading.Event.set `.
1255
+ ``start_threads `` will attempt to join the started threads upon exit.
1237
1256
1238
1257
1239
1258
.. function :: threading_cleanup(*original_values)
@@ -1315,7 +1334,10 @@ The :mod:`test.support.os_helper` module provides support for os tests.
1315
1334
1316
1335
.. data :: TESTFN_NONASCII
1317
1336
1318
- Set to a filename containing the :data: `FS_NONASCII ` character.
1337
+ Set to a filename containing the :data: `FS_NONASCII ` character, if it exists.
1338
+ This guarantees that if the filename exists, it can be encoded and decoded
1339
+ with the default filesystem encoding. This allows tests that require a
1340
+ non-ASCII filename to be easily skipped on platforms where they can't work.
1319
1341
1320
1342
1321
1343
.. data :: TESTFN_UNENCODABLE
@@ -1413,13 +1435,16 @@ The :mod:`test.support.os_helper` module provides support for os tests.
1413
1435
.. function :: rmdir(filename)
1414
1436
1415
1437
Call :func: `os.rmdir ` on *filename *. On Windows platforms, this is
1416
- wrapped with a wait loop that checks for the existence of the file.
1438
+ wrapped with a wait loop that checks for the existence of the file,
1439
+ which is needed due to antivirus programs that can hold files open and prevent
1440
+ deletion.
1417
1441
1418
1442
1419
1443
.. function :: rmtree(path)
1420
1444
1421
1445
Call :func: `shutil.rmtree ` on *path * or call :func: `os.lstat ` and
1422
- :func: `os.rmdir ` to remove a path and its contents. On Windows platforms,
1446
+ :func: `os.rmdir ` to remove a path and its contents. As with :func: `rmdir `,
1447
+ on Windows platforms
1423
1448
this is wrapped with a wait loop that checks for the existence of the files.
1424
1449
1425
1450
@@ -1466,7 +1491,8 @@ The :mod:`test.support.os_helper` module provides support for os tests.
1466
1491
1467
1492
.. function :: unlink(filename)
1468
1493
1469
- Call :func: `os.unlink ` on *filename *. On Windows platforms, this is
1494
+ Call :func: `os.unlink ` on *filename *. As with :func: `rmdir `,
1495
+ on Windows platforms, this is
1470
1496
wrapped with a wait loop that checks for the existence of the file.
1471
1497
1472
1498
@@ -1523,7 +1549,7 @@ The :mod:`test.support.import_helper` module provides support for import tests.
1523
1549
.. versionadded :: 3.1
1524
1550
1525
1551
1526
- .. function :: import_module(name, deprecated=False, *, required_on())
1552
+ .. function :: import_module(name, deprecated=False, *, required_on= ())
1527
1553
1528
1554
This function imports and returns the named module. Unlike a normal
1529
1555
import, this function raises :exc: `unittest.SkipTest ` if the module
@@ -1565,15 +1591,15 @@ The :mod:`test.support.import_helper` module provides support for import tests.
1565
1591
1566
1592
A context manager to force import to return a new module reference. This
1567
1593
is useful for testing module-level behaviors, such as the emission of a
1568
- DeprecationWarning on import. Example usage::
1594
+ :exc: ` DeprecationWarning ` on import. Example usage::
1569
1595
1570
1596
with CleanImport('foo'):
1571
1597
importlib.import_module('foo') # New reference.
1572
1598
1573
1599
1574
1600
.. class :: DirsOnSysPath(*paths)
1575
1601
1576
- A context manager to temporarily add directories to sys.path.
1602
+ A context manager to temporarily add directories to :data: ` sys.path ` .
1577
1603
1578
1604
This makes a copy of :data: `sys.path `, appends any directories given
1579
1605
as positional arguments, then reverts :data: `sys.path ` to the copied
0 commit comments