summaryrefslogtreecommitdiffstats
path: root/Lib/test/support
Commit message (Collapse)AuthorAgeFilesLines
* [3.9] bpo-40173: Fix test.support.import_helper.import_fresh_module() ↵Serhiy Storchaka2021-09-301-42/+27
| | | | | | | | | | | | | | | (GH-28654) (GH-28658) * Work correctly if an additional fresh module imports other additional fresh module which imports a blocked module. * Raises ImportError if the specified module cannot be imported while all additional fresh modules are successfully imported. * Support blocking packages. * Always restore the import state of fresh and blocked modules and their submodules. * Fix test_decimal and test_xml_etree which depended on an undesired side effect of import_fresh_module(). (cherry picked from commit ec4d917a6a68824f1895f75d113add9410283da7)
* [3.9] [codemod] Fix non-matching bracket pairs (GH-28473) (GH-28512)Łukasz Langa2021-09-221-2/+2
| | | | | | | | Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl>. (cherry picked from commit 8f943ca25732d548cf9f0b0393ba8d582fb93e29) Co-authored-by: Mohamad Mansour <66031317+mohamadmansourX@users.noreply.github.com>
* [3.9] bpo-45229: Remove test_main in many tests (GH-28405) (GH-28456)Serhiy Storchaka2021-09-201-8/+2
| | | | | | | | | | | Instead of explicitly enumerate test classes for run_unittest() use the unittest ability to discover tests. This also makes these tests discoverable and runnable with unittest. load_tests() can be used for dynamic generating tests and adding doctests. setUpModule(), tearDownModule() and addModuleCleanup() can be used for running code before and after all module tests.. (cherry picked from commit 40348acc180580371d25f75f46b27048e35f2435)
* [3.9] bpo-45042: Now test classes decorated with `requires_hashdigest` are ↵Serhiy Storchaka2021-09-051-3/+16
| | | | | | | | | not skipped (GH-28060) (GH-28169) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>. (cherry picked from commit dd7b816ac87e468e2fa65ce83c2a03fe1da8503e) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* [3.9] bpo-45057: Simplify RegressionTestResult (GH-28081) (GH-28103)Serhiy Storchaka2021-09-011-31/+2
| | | | | Remove code which duplicates the functionality of TextTestResult. (cherry picked from commit 2b76a5322fdf71d62b531fd765085f96f981c244)
* bpo-44852: Support filtering over warnings without a set message (GH-27793) ↵Miss Islington (bot)2021-08-181-4/+5
| | | | | | | | | | | | | | | (GH-27810) Additional improvements: - messages which were compiled regular expressions aren't unpacked back into strings for unmatched warnings; - removed unnecessary "if tokens:" check (there's one before the for loop); - took `endswith` calculation out of the for loop. (cherry picked from commit 8cf07d3db3eed02b43350a5f9dbf68f1c839ea82) Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* [3.9] bpo-44852: Support ignoring specific DeprecationWarnings wholesale in ↵Łukasz Langa2021-08-162-0/+227
| | | | | | | regrtest (GH-27634) (GH-27785) (cherry picked from commit a0a6d39295a30434b088f4b66439bf5ea21a3e4e) Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* [3.9] bpo-40928: notify users running test_decimal on macOS of malloc ↵Łukasz Langa2021-08-061-0/+19
| | | | | | | | | | | warnings (GH-26783) (GH-27629) * When trying to allocate very large regions on macOS, malloc does not fail silently. It sends a noisy error out to STDERR * This provides a helper function to warn the user, and provides the warning for test_decimal, which consistently generates these warnings on macOS. Co-authored-by: Łukasz Langa <lukasz@langa.pl>. (cherry picked from commit 15d3c14df32a35ac69898a7852115722e30d7857) Co-authored-by: Jack DeVries <58614260+jdevries3133@users.noreply.github.com>
* [3.9] bpo-44708: Only re-run test methods that match names of previously ↵Łukasz Langa2021-07-221-1/+14
| | | | | | | | | | | | | | failing test methods (GH-27287) (GH-27293) * Move to a static argparse.Namespace subclass * Roughly annotate runtest.py * Refactor libregrtest to use lossless test result objects * Only re-run test methods that match names of previously failing test methods * Adopt tests to cover test method name matching Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>. (cherry picked from commit f1afef5e0d93d66fbf3c9aaeab8b3b8da9617583) Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* [3.9] bpo-11105: reduce the recursion limit for tests. (GH-26605)Batuhan Taskaya2021-06-081-0/+10
| | | | | (cherry picked from commit e58d762c1fb4ad5e021d016c80c2bc4513632d2f) Co-authored-by: Batuhan Taskaya <batuhan@python.org>
* bpo-41172: Fix check for compiler in test suite (GH-21400)Miss Islington (bot)2020-07-091-1/+7
| | | | | (cherry picked from commit af56c4fc76ac39ce76d649d7bebf7f78c1add4fa) Co-authored-by: Steve Dower <steve.dower@python.org>
* [3.9] bpo-41043: Escape literal part of the path for glob(). (GH-20994). ↵Serhiy Storchaka2020-07-021-1/+1
| | | | | (GH-21275) (cherry picked from commit 935586845815f5b4c7814794413f6a812d4bd45f)
* [3.9] bpo-41069: Make TESTFN and the CWD for tests containing non-ascii ↵Serhiy Storchaka2020-06-251-10/+11
| | | | | | characters. (GH-21035). (GH-21156) (cherry picked from commit 700cfa8c90a90016638bac13c4efd03786b2b2a0)
* [3.9] bpo-41009: fix requires_OS_version() class decorator (GH-20942) (GH-20947)Christian Heimes2020-06-251-19/+19
| | | | | | | | Signed-off-by: Christian Heimes <christian@python.org> Automerge-Triggered-By: @tiran. (cherry picked from commit bb6ec14479f18c32e71e43f2785f177aa17aabbd) Co-authored-by: Christian Heimes <christian@python.org>
* bpo-38377: Fix skip_if_broken_multiprocessing_synchronize() on macOS (GH-20984)Miss Islington (bot)2020-06-191-8/+9
| | | | | | | | skip_if_broken_multiprocessing_synchronize() only attempts for create a semaphore on Linux to fix multiprocessing test_resource_tracker_reused() on macOS. (cherry picked from commit 3358da4054b9b0b045eb47dc74dee3d58bfbb1d5) Co-authored-by: Victor Stinner <vstinner@python.org>
* bpo-38377: Add support.skip_if_broken_multiprocessing_synchronize() ↵Victor Stinner2020-06-181-0/+23
| | | | | | | | | | (GH-20944) (GH-20962) On Linux, skip tests using multiprocessing if the current user cannot create a file in /dev/shm/ directory. Add the skip_if_broken_multiprocessing_synchronize() function to the test.support module. (cherry picked from commit ddbeb2f3e02a510c5784ffd74c5e09e8c70b5881)
* bpo-41003: Fix test_copyreg when numpy is installed (GH-20935) (GH-20945)Victor Stinner2020-06-171-0/+9
| | | | | | | | | | Fix test_copyreg when numpy is installed: test.pickletester now saves/restores warnings.filters when importing numpy, to ignore filters installed by numpy. Add the save_restore_warnings_filters() function to the test.support.warnings_helper module. (cherry picked from commit 8362893e3fe083df2ec8bb94c28b1a78383eadbf)
* bpo-40826: Fix test_repl.test_close_stdin() on Windows (GH-20779) (GH-20785)Victor Stinner2020-06-101-17/+34
| | | | | | | | | | | | | test_repl.test_close_stdin() now calls support.suppress_msvcrt_asserts() to fix the test on Windows. * Move suppress_msvcrt_asserts() from test.libregrtest.setup to test.support. Make its verbose parameter optional: verbose=False by default. * SuppressCrashReport now uses SetErrorMode() of the msvcrt module, rather than using ctypes. * Remove also an unused variable (deadline) in wait_process(). (cherry picked from commit f6e58aefde2e57e4cb11ea7743955da53a3f1e80)
* bpo-40275: More lazy imports in test.support (GH-20131)Hai Shi2020-05-181-35/+39
| | | | | | | | | | | | | | | | | | | Make the the following imports lazy in test.support: * bz2 * gzip * lzma * resource * zlib The following test.support decorators now need to be called with parenthesis: * @support.requires_bz2 * @support.requires_gzip * @support.requires_lzma * @support.requires_zlib For example, "@requires_zlib" becomes "@requires_zlib()".
* bpo-40275: lazy import modules in test.support (GH-20128)Hai Shi2020-05-161-4/+9
| | | Automerge-Triggered-By: @vstinner
* bpo-40275: test.support imports lazily locale import (GH-19761)Hai Shi2020-05-041-1/+1
|
* bpo-40275: Fix name error in support.socket_helper (GH-19825)Victor Stinner2020-05-011-4/+6
| | | | | Replace TestFailed with support.TestFailed. Bug spotted by pyflakes.
* Add missing sys import to socket_helper.py (GH-19791)Pablo Galindo2020-04-291-0/+1
|
* bpo-40275: Move transient_internet from test.support to socket_helper (GH-19711)Serhiy Storchaka2020-04-292-87/+90
|
* bpo-40275: Move requires_hashdigest() to test.support.hashlib_helper (GH-19716)Hai Shi2020-04-292-37/+39
| | | Add a new test.support.hashlib_helper submodule.
* bpo-40275: Avoid importing logging in test.support (GH-19601)Serhiy Storchaka2020-04-252-34/+29
| | | | | Import logging lazily in assertLogs() in unittest. Move TestHandler from test.support to logging_helper.
* bpo-40275: Avoid importing socket in test.support (GH-19603)Serhiy Storchaka2020-04-252-183/+182
| | | | | | * Move socket related functions from test.support to socket_helper. * Import socket, nntplib and urllib.error lazily in transient_internet(). * Remove importing multiprocess.
* bpo-40275: Avoid importing asyncio in test.support (GH-19600)Serhiy Storchaka2020-04-251-1/+1
| | | | | * Import asyncio lazily in unittest (only when IsolatedAsyncioTestCase is used). * Import asyncio.events lazily in test.support.
* bpo-39983: Add test.support.print_warning() (GH-19683)Victor Stinner2020-04-231-9/+12
| | | | | | | Log "Warning -- ..." test warnings into sys.__stderr__ rather than sys.stderr, to ensure to display them even if sys.stderr is captured. test.libregrtest.utils.print_warning() now calls test.support.print_warning().
* bpo-40334: Rename PyConfig.use_peg to _use_peg_parser (GH-19670)Victor Stinner2020-04-231-0/+10
| | | | | | | | | | | * Rename PyConfig.use_peg to _use_peg_parser * Document PyConfig._use_peg_parser and mark it a deprecated * Mark -X oldparser option and PYTHONOLDPARSER env var as deprecated in the documentation. * Add use_old_parser() and skip_if_new_parser() to test.support * Remove sys.flags.use_peg: use_old_parser() uses _testinternalcapi.get_configs() instead. * Enhance test_embed tests * subprocess._args_from_interpreter_flags() copies -X oldparser
* bpo-40241: Add pycore_gc.h header file (GH-19494)Victor Stinner2020-04-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Move the PyGC_Head structure and the following private macros to the internal C API: * _PyGCHead_FINALIZED() * _PyGCHead_NEXT() * _PyGCHead_PREV() * _PyGCHead_SET_FINALIZED() * _PyGCHead_SET_NEXT() * _PyGCHead_SET_PREV() * _PyGC_FINALIZED() * _PyGC_PREV_MASK * _PyGC_PREV_MASK_COLLECTING * _PyGC_PREV_MASK_FINALIZED * _PyGC_PREV_SHIFT * _PyGC_SET_FINALIZED() * _PyObject_GC_IS_TRACKED() * _PyObject_GC_MAY_BE_TRACKED() * _Py_AS_GC(o) Keep the private _PyGC_FINALIZED() macro in the public C API for backward compatibility with Python 3.8: make it an alias to the new PyObject_GC_IsFinalized() function. Move the SIZEOF_PYGC_HEAD constant from _testcapi module to _testinternalcapi module.
* bpo-40094: Add os.waitstatus_to_exitcode() (GH-19201)Victor Stinner2020-04-011-8/+1
| | | | | | | | | | | | | | Add os.waitstatus_to_exitcode() function to convert a wait status to an exitcode. Suggest waitstatus_to_exitcode() usage in the documentation when appropriate. Use waitstatus_to_exitcode() in: * multiprocessing, os, subprocess and _bootsubprocess modules; * test.support.wait_process(); * setup.py: run_command(); * and many tests.
* bpo-40094: Add missing import to wait_process() (GH-19268)Victor Stinner2020-04-011-0/+2
|
* bpo-40094: Add test.support.wait_process() (GH-19254)Victor Stinner2020-03-311-0/+59
| | | | | | | | | Moreover, the following tests now check the child process exit code: * test_os.PtyTests * test_mailbox.test_lock_conflict() * test_tempfile.test_process_awareness() * test_uuid.testIssue8621() * multiprocessing resource tracker tests
* bpo-39489: Remove COUNT_ALLOCS special build (GH-18259)Victor Stinner2020-02-031-3/+0
| | | | | | | | | | | Remove: * COUNT_ALLOCS macro * sys.getcounts() function * SHOW_ALLOC_COUNT code in listobject.c * SHOW_TRACK_COUNT code in tupleobject.c * PyConfig.show_alloc_count field * -X showalloccount command line option * @test.support.requires_type_collecting decorator
* bpo-38991: Remove test.support.strip_python_stderr() (GH-17490)Victor Stinner2019-12-082-12/+1
| | | | | test.support: run_python_until_end(), assert_python_ok() and assert_python_failure() functions no longer strip whitespaces from stderr.
* bpo-37957: Allow regrtest to receive a file with test (and subtests) to ↵Pablo Galindo2019-11-191-12/+38
| | | | | | | ignore (GH-16989) When building Python in some uncommon platforms there are some known tests that will fail. Right now, the test suite has the ability to ignore entire tests using the -x option and to receive a filter file using the --matchfile filter. The problem with the --matchfile option is that it receives a file with patterns to accept and when you want to ignore a couple of tests and subtests, is too cumbersome to lists ALL tests that are not the ones that you want to accept and he problem with -x is that is not easy to ignore just a subtests that fail and the whole test needs to be ignored. For these reasons, add a new option to allow to ignore a list of test and subtests for these situations.
* bpo-38614: Add timeout constants to test.support (GH-16964)Victor Stinner2019-10-301-5/+56
| | | | | | | | Add timeout constants to test.support: * LOOPBACK_TIMEOUT * INTERNET_TIMEOUT * SHORT_TIMEOUT * LONG_TIMEOUT
* bpo-38453: Resolve test directories before chdir to them (GH-16723)Steve Dower2019-10-141-1/+1
|
* bpo-38270: More fixes for strict crypto policy (GH-16418)Christian Heimes2019-09-271-4/+16
| | | | | | | | | | | | | | | test_hmac and test_hashlib test built-in hashing implementations and OpenSSL-based hashing implementations. Add more checks to skip OpenSSL implementations when a strict crypto policy is active. Use EVP_DigestInit_ex() instead of EVP_DigestInit() to initialize the EVP context. The EVP_DigestInit() function clears alls flags and breaks usedforsecurity flag again. Signed-off-by: Christian Heimes <christian@python.org> https://bugs.python.org/issue38270
* bpo-38270: Check for hash digest algorithms and avoid MD5 (GH-16382)Christian Heimes2019-09-251-0/+24
| | | | | | | | | | | Make it easier to run and test Python on systems with restrict crypto policies: * add requires_hashdigest to test.support to check if a hash digest algorithm is available and working * avoid MD5 in test_hmac * replace MD5 with SHA256 in test_tarfile * mark network tests that require MD5 for MD5-based digest auth or CRAM-MD5 https://bugs.python.org/issue38270
* bpo-18578: Rename and document test.bytecode_helper as ↵Joannah Nanjekye2019-09-121-0/+41
| | | | | test.support.bytecode_helper (GH-15168) Rename and document test.bytecode_helper as test.support.bytecode_helper
* bpo-37583: Add err 113 to support.get_socket_conn_refused_errs() (GH-14729)Hai Shi2019-08-131-0/+3
| | | | | Add error number 113 EHOSTUNREACH to get_socket_conn_refused_errs() of test.support.
* bpo-37685: Use singletons ALWAYS_EQ and NEVER_EQ in more tests. (GH-15167)Serhiy Storchaka2019-08-081-0/+2
|
* bpo-37648: Fixed minor inconsistency in some __contains__. (GH-14904)Serhiy Storchaka2019-08-041-1/+12
| | | | | The collection's item is now always at the left and the needle is on the right of ==.
* bpo-37685: Fixed comparisons of datetime.timedelta and datetime.timezone. ↵Serhiy Storchaka2019-08-041-0/+36
| | | | | | | | | (GH-14996) There was a discrepancy between the Python and C implementations. Add singletons ALWAYS_EQ, LARGEST and SMALLEST in test.support to test mixed type comparison.
* bpo-37707: Exclude expensive unit tests from PGO task (GH-15009)Neil Schemenauer2019-07-301-0/+10
| | | | | Mark some individual tests to skip when --pgo is used. The tests marked increase the PGO task time significantly and likely don't help improve optimization of the final executable.
* Fix typos in docs, comments and test assert messages (#14872)Min ho Kim2019-07-211-1/+1
|
* bpo-37552: Skip failing tests in strptime/strftime with UCRT version ↵Paul Monson2019-07-181-1/+23
| | | | | 17763.615 (#14460) A bug in MSVC UCRT version 17763.615 (which has been fixed in newer versions) is causing test failures in some strptime/strftime tests when the default code page is c65001. This change selectively skips the tests affected by this.
* bpo-37526: Add support.catch_threading_exception() (GH-14664)Victor Stinner2019-07-091-0/+57
| | | | Context manager catching threading.Thread exception using threading.excepthook.