summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_support.py
Commit message (Collapse)AuthorAgeFilesLines
* gh-104835: Remove unittest's deprecated getTestCaseNames, makeSuite, ↵Hugo van Kemenade2023-05-241-3/+0
| | | | findTestCases (#104836)
* gh-104057: Fix direct invocation of test_support (GH-104069)Kirill Podoprigora2023-05-111-1/+1
|
* Add test.support.busy_retry() (#93770)Victor Stinner2022-06-151-11/+1
| | | Add busy_retry() and sleeping_retry() functions to test.support.
* gh-90473: WASI: skip gethostname tests (GH-93092)Christian Heimes2022-05-231-0/+1
| | | | | | - WASI's ``gethostname()`` is a stub that always fails with OSError ``ENOTSUP`` - skip mailcap ``test`` if subprocess is not available - WASI process_time clock does not work.
* gh-90473: Skip tests that don't apply to Emscripten and WASI (GH-92846)Christian Heimes2022-05-161-1/+1
|
* gh-57684: Add -P cmdline option and PYTHONSAFEPATH env var (#31542)Victor Stinner2022-05-051-1/+3
| | | | | | | | | | | | Add the -P command line option and the PYTHONSAFEPATH environment variable to not prepend a potentially unsafe path to sys.path. * Add sys.flags.safe_path flag. * Add PyConfig.safe_path member. * Programs/_bootstrap_python.c uses config.safe_path=0. * Update subprocess._optim_args_from_interpreter_flags() to handle the -P command line option. * Modules/getpath.py sets safe_path to 1 if a "._pth" file is present.
* bpo-40280: Detect missing threading on WASM platforms (GH-32352)Christian Heimes2022-04-071-0/+3
| | | Co-authored-by: Brett Cannon <brett@python.org>
* bpo-40280: Skip more tests on Emscripten (GH-31947)Christian Heimes2022-03-171-0/+3
| | | | | | - lchmod, lchown are not fully implemented - skip umask tests - cannot fstat unlinked or renamed files yet - ignore musl libc issues that affect Emscripten
* bpo-46587: Skip tests if strftime does not support glibc extension (GH-31873)Christian Heimes2022-03-151-0/+6
| | | Co-authored-by: Victor Stinner <vstinner@python.org>
* bpo-40280: Skip subprocess-based tests on wasm32-emscripten (GH-30615)Christian Heimes2022-01-251-0/+1
|
* bpo-40280: Add requires_fork test helper (GH-30622)Christian Heimes2022-01-161-1/+2
|
* bpo-45410: regrtest -W leaves stdout/err FD unchanged (GH-28915)Victor Stinner2021-10-131-12/+2
| | | | | | | | | | | | support.print_warning() now stores the original value of sys.__stderr__ and uses it to log warnings. libregrtest uses the same stream to log unraisable exceptions and uncaught threading exceptions. Partially revert commit dbe213de7ef28712bbfdb9d94a33abb9c33ef0c2: libregrtest no longer replaces sys.__stdout__, sys.__stderr__, and stdout and stderr file descriptors. Remove also a few unused imports in libregrtest.
* bpo-45229: Remove test_main in many tests (GH-28405)Serhiy Storchaka2021-09-191-5/+1
| | | | | | | | | 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.
* bpo-5846: Deprecate obsolete methods in `unittest` (GH-28299)Erlend Egeberg Aasland2021-09-151-2/+7
| | | Deprecate makeSuite, findTestCases, and getTestCaseNames. Scheduled for removal in Python 3.13.
* bpo-44852: Support ignoring specific DeprecationWarnings wholesale in ↵Łukasz Langa2021-08-161-0/+29
| | | | regrtest (GH-27634)
* bpo-44498: Issue a deprecation warning on asynchat, asyncore and smtpd ↵Barry Warsaw2021-06-241-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | import (#26882) * Issue a deprecation warning on smtpd import * Also issue DeprecationWarnings for asynchat and asyncore * Fix some tests * test___all__ requires the word 'module' or 'package' in the deprecation warning text, so add those to smtpd, asynchat, and asyncore. * In test_support, use pprint now instead of asyncore as the landmark. * Add What's New * Use ..deprecated:: * Use ..deprecated:: * Update Lib/smtpd.py Co-authored-by: Miro Hrončok <miro@hroncok.cz> * Update Doc/library/smtpd.rst Co-authored-by: Miro Hrončok <miro@hroncok.cz> * Import async{hat,ore} after the DeprecationWarning for this module Co-authored-by: Miro Hrončok <miro@hroncok.cz>
* bpo-43651: PEP 597: Fix EncodingWarning in some tests (GH-25142)Inada Naoki2021-04-021-2/+2
| | | | | | | | | | | | | * test__xxsubinterpreters * test_builtin * test_doctest * test_exceptions * test_opcodes * test_support * test_argparse * test_baseexception * test_bdb * test_bool * test_asdl_parser
* bpo-41521: Rename blacklist parameter to not_exported (GH-21824)Victor Stinner2020-08-171-4/+4
| | | | Rename "blacklist" parameter of test.support.check__all__() to "not_exported".
* bpo-40275: Use new test.support helper submodules in tests (GH-21169)Hai Shi2020-06-301-38/+43
|
* bpo-40275: Move TransientResource to test_urllib2net (GH-20812)Victor Stinner2020-06-111-1/+0
| | | | | | Move TransientResource, time_out, socket_peer_reset and ioerror_peer_reset from test.support to test_urllib2net. Remove "import errno" from test.support.
* bpo-40443: Remove unused imports in tests (GH-19805)Victor Stinner2020-04-291-1/+0
|
* bpo-40275: Avoid importing socket in test.support (GH-19603)Serhiy Storchaka2020-04-251-4/+5
| | | | | | * Move socket related functions from test.support to socket_helper. * Import socket, nntplib and urllib.error lazily in transient_internet(). * Remove importing multiprocess.
* bpo-39983: Add test.support.print_warning() (GH-19683)Victor Stinner2020-04-231-1/+23
| | | | | | | 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-40094: Add test.support.wait_process() (GH-19254)Victor Stinner2020-03-311-5/+2
| | | | | | | | | 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-1/+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-38614: Use test.support.SHORT_TIMEOUT constant (GH-17566)Victor Stinner2019-12-111-1/+1
| | | | | | | | | | | | | | | Replace hardcoded timeout constants in tests with SHORT_TIMEOUT of test.support, so it's easier to ajdust this timeout for all tests at once. SHORT_TIMEOUT is 30 seconds by default, but it can be longer depending on --timeout command line option. The change makes almost all timeouts longer, except test_reap_children() of test_support which is made 2x shorter: SHORT_TIMEOUT should be enough. If this test starts to fail, LONG_TIMEOUT should be used instead. Uniformize also "from test import support" import in some test files.
* bpo-38991: Remove test.support.strip_python_stderr() (GH-17490)Victor Stinner2019-12-081-1/+0
| | | | | 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-9/+57
| | | | | | | 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-32972: Async test case (GH-13386)Andrew Svetlov2019-05-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add explicit `asyncSetUp` and `asyncTearDown` methods. The rest is the same as for #13228 `AsyncTestCase` create a loop instance for every test for the sake of test isolation. Sometimes a loop shared between all tests can speed up tests execution time a lot but it requires control of closed resources after every test finish. Basically, it requires nested supervisors support that was discussed with @1st1 many times. Sorry, asyncio supervisors have no chance to land on Python 3.8. The PR intentionally does not provide API for changing the used event loop or getting the test loop: use `asyncio.set_event_loop_policy()` and `asyncio.get_event_loop()` instead. The PR adds four overridable methods to base `unittest.TestCase` class: ``` def _callSetUp(self): self.setUp() def _callTestMethod(self, method): method() def _callTearDown(self): self.tearDown() def _callCleanup(self, function, /, *args, **kwargs): function(*args, **kwargs) ``` It allows using asyncio facilities with minimal influence on the unittest code. The last but not least: the PR respects contextvars. The context variable installed by `asyncSetUp` is available on test, `tearDown` and a coroutine scheduled by `addCleanup`. https://bugs.python.org/issue32972
* bpo-35934: Add socket.create_server() utility function (GH-11784)Giampaolo Rodola2019-04-081-4/+2
|
* bpo-34812: subprocess._args_from_interpreter_flags(): add isolated (GH-10675)Victor Stinner2018-11-231-2/+8
| | | | | | | | The "-I" command line option (run Python in isolated mode) is now also copied by the multiprocessing and distutils modules when spawning child processes. Previously, only -E and -s options (enabled by -I) were copied. subprocess._args_from_interpreter_flags() now copies the -I flag.
* bpo-34683: Make SyntaxError column offsets consistently 1-indexed (gh-9338)Ammar Askar2018-09-241-1/+1
| | | | | | Also point to start of tokens in parsing errors. Fixes bpo-34683
* Fixed several assertTrue() that were intended to be assertEqual(). (GH-8191)Sergey Fedoseev2018-07-091-1/+1
| | | Fixed also testing the "always" warning filter.
* bpo-33773: Fix test.support.fd_count() on Linux/FreBSD (GH-7421)Victor Stinner2018-06-061-0/+11
| | | | | | | | | Substract one because listdir() opens internally a file descriptor to list the content of the /proc/self/fd/ directory. Add test_support.test_fd_count(). Move also MAXFD code before msvcrt.CrtSetReportMode(), to make sure that the report mode is always restored on failure.
* bpo-30028: make test.support.temp_cwd() fork-safe (GH-1066)Anselm Kruis2018-02-231-0/+29
| | | | Make test.support.temp_cwd() fork-safe. The context manager test.support.temp_cwd() no longer removes the temporary directory when executing in a process other than the parent it entered from. If a forked child exits the context manager it won't do the cleanup.
* bpo-31324: Fix test.support.set_match_tests(None) (#4505)Victor Stinner2017-11-221-0/+5
|
* bpo-31324: Optimize support._match_test() (#4421)Victor Stinner2017-11-211-0/+53
| | | | | | | | | | | * Rename support._match_test() to support.match_test(): make it public * Remove support.match_tests global variable. It is replaced with a new support.set_match_tests() function, so match_test() doesn't have to check each time if patterns were modified. * Rewrite match_test(): use different code paths depending on the kind of patterns for best performances. Co-Authored-By: Serhiy Storchaka <storchaka@gmail.com>
* bpo-32094: Update subprocess for -X dev (#4480)Victor Stinner2017-11-201-1/+57
| | | | | | | | Modify subprocess._args_from_interpreter_flags() to handle -X dev option. Add also unit tests for test.support.args_from_interpreter_flags() and test.support.optim_args_from_interpreter_flags().
* Enhance support.reap_children() (#3036)Victor Stinner2017-08-101-5/+52
| | | | | | | * reap_children() now sets environment_altered to True to detect bugs using python3 -m test --fail-env-changed * Replace bare "except:" with "except OSError:" in reap_children() * Write an unit test for reap_children() using a timeout of 60 seconds
* bpo-30197: Enhance functions swap_attr() and swap_item() in test.support. ↵Serhiy Storchaka2017-04-281-6/+23
| | | | | | | | | | | | | (#1341) * bpo-30197: Enhance functions swap_attr() and swap_item() in test.support. They now work when delete replaced attribute or item inside the with statement. The old value of the attribute or item (or None if it doesn't exist) now will be assigned to the target of the "as" clause, if there is one. * Update docstrings.
* support: temp_dir() and change_cwd() uses repr() in error messageVictor Stinner2017-02-081-3/+3
| | | | | Serhiy Storshaka pointed me that str(path) can emit a BytesWarning: use repr(path) instead.
* Update test_support for my temp_dir/change_cwd changesVictor Stinner2017-02-081-5/+18
|
* Issue #28512: Fixed setting the offset attribute of SyntaxError bySerhiy Storchaka2016-12-111-1/+1
|\ | | | | | | PyErr_SyntaxLocationEx() and PyErr_SyntaxLocationObject().
| * Issue #28512: Fixed setting the offset attribute of SyntaxError bySerhiy Storchaka2016-12-111-1/+3
| | | | | | | | PyErr_SyntaxLocationEx() and PyErr_SyntaxLocationObject().
* | Issue #28666: Now test.support.rmtree is able to remove unwritable orSerhiy Storchaka2016-11-201-12/+23
|\ \ | |/ | | | | unreadable directories.
| * Issue #28666: Now test.support.rmtree is able to remove unwritable orSerhiy Storchaka2016-11-201-10/+23
| | | | | | | | unreadable directories.
* | Replace noop constant statement with expressionVictor Stinner2016-02-081-1/+2
| | | | | | | | | | | | | | | | | | | | * Constant statements will be ignored and the compiler will emit a SyntaxWarning. * Replace constant statement (ex: "1") with an expression statement (ex: "x=1"). * test_traceback: use context manager on the file. Issue #26204.
* | Issue #25695: Defer creation of TESTDIRN until the test case is runMartin Panter2015-11-241-2/+4
| |
* | Issue #23883: Add test.support.check__all__() and test gettext.__all__Martin Panter2015-11-141-0/+22
|/ | | | Patches by Jacek Kołodziej.
* issue9859: Document test.support.detect_api_mismatch() and simplify its test.Gregory P. Smith2015-04-141-30/+20
|