summaryrefslogtreecommitdiffstats
path: root/Lib/test/support
Commit message (Collapse)AuthorAgeFilesLines
* gh-128595: Add test class helper to force no terminal colour (#128687)Hugo van Kemenade2025-01-131-16/+31
| | | | Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* gh-128192: mark new tests with skips based on hashlib algorithm availability ↵Gregory P. Smith2024-12-291-0/+8
| | | | | (gh-128324) Puts the _hashlib get_fips_mode logic check into test.support rather than spreading it out among other tests.
* gh-128265: Support WASI/Emscripten on PDB tests, by removing asyncio from ↵Thomas Grainger2024-12-281-0/+29
| | | | | | | | | | | pdb tests (#128264) A part of `Lib/test/test_pdb.py` was previously unable to run on WASI/Emscripten platforms because it lacked support for `asyncio`. In fact, these tests could be rewritten without the `asyncio` framework because `test_pdb` tests the behavior of coroutines, which are not part of `asyncio`. Now reliance on the availability of `asyncio` has been removed and part of `test_pdb` that deals with coroutines working on WASI/Emscripten platforms.
* gh-127747: Resolve BytesWarning in test.support.strace_helper (#127849)Cody Maloney2024-12-141-4/+5
| | | | | | | | | | | | | | | | | | | | | The strace_helper code has a _make_error function to simplify making StraceResult objects in error cases. That takes a details parameter which is either a caught OSError or `bytes`. If it's bytes, _make_error would implicitly coerce that to a str inside of a f-string, resulting in a BytesWarning. It's useful to see if it's an OSError or bytes when debugging, resolve by changing to format with repr(). This is an error message on an internal helper. A non-zero exit code occurs if the strace binary isn't found, and no events will be parsed in that case (there is no output). Handle that case by checking exit code before checking for events. Still asserting around events rather than returning false, so that hopefully if there's some change to `strace` that breaks the parsing, will see that as a test failure rather than silently loosing strace tests because they are auto-disabled.
* gh-127146: Emscripten: Skip segfaults in test suite (#127151)Hood Chatham2024-12-051-0/+3
| | | | Added skips for tests known to cause problems when running on Emscripten. These mostly relate to the limited stack depth on Emscripten.
* gh-127076: Ignore memory mmap in FileIO testing (#127088)Cody Maloney2024-11-221-5/+29
| | | | | | | | | | | | | `mmap`, `munmap`, and `mprotect` are used by CPython for memory management, which may occur in the middle of the FileIO tests. The system calls can also be used with files, so `strace` includes them in its `%file` and `%desc` filters. Filter out the `mmap` system calls related to memory allocation for the file tests. Currently FileIO doesn't do `mmap` at all, so didn't add code to track from `mmap` through `munmap` since it wouldn't be used. For now if an `mmap` on a fd happens, the call will be included (which may cause test to fail), and at that time support for tracking the address throug `munmap` could be added.
* gh-127076: Disable strace tests under LD_PRELOAD (#127086)Cody Maloney2024-11-211-0/+8
| | | | | | | | Distribution tooling (ex. sandbox on Gentoo and fakeroot on Debian) uses LD_PRELOAD to intercept system calls and potentially modify them when building. These tools can change the set of system calls, so disable system call testing under these cases. Co-authored-by: Michał Górny <mgorny@gentoo.org>
* GH-126892: Reset warmup counters when JIT compiling code (GH-126893)Brandt Bucher2024-11-201-1/+4
|
* gh-118201: Simplify conv_confname (#126089)Malcolm Smith2024-11-191-2/+1
|
* GH-126789: fix some sysconfig data on late site initializationsFilipe Laíns 🇵🇸2024-11-171-0/+70
|
* gh-126413: Add translation tests for getopt and optparse (GH-126698)Tomas R.2024-11-111-0/+63
|
* gh-115999: Implement thread-local bytecode and enable specialization for ↵mpage2024-11-041-0/+5
| | | | | | | | | `BINARY_OP` (#123926) Each thread specializes a thread-local copy of the bytecode, created on the first RESUME, in free-threaded builds. All copies of the bytecode for a code object are stored in the co_tlbc array on the code object. Threads reserve a globally unique index identifying its copy of the bytecode in all co_tlbc arrays at thread creation and release the index at thread destruction. The first entry in every co_tlbc array always points to the "main" copy of the bytecode that is stored at the end of the code object. This ensures that no bytecode is copied for programs that do not use threads. Thread-local bytecode can be disabled at runtime by providing either -X tlbc=0 or PYTHON_TLBC=0. Disabling thread-local bytecode also disables specialization. Concurrent modifications to the bytecode made by the specializing interpreter and instrumentation use atomics, with specialization taking care not to overwrite an instruction that was instrumented concurrently.
* gh-120754: Add a strace helper and test set of syscalls for open().read(), ↵Cody Maloney2024-11-031-0/+170
| | | | Take 2 (#123413)
* Android: Update tests for newly-available functions affected by SELinux ↵Malcolm Smith2024-10-271-0/+5
| | | | | (#126015) Skip tests on Android that involve use of SELinux-protected methods.
* gh-125900: Clean-up logic around immortalization in free-threading (#125901)Sam Gross2024-10-241-27/+0
| | | | | | | | | * Remove `@suppress_immortalization` decorator * Make suppression flag per-thread instead of per-interpreter * Suppress immortalization in `eval()` to avoid refleaks in three tests (test_datetime.test_roundtrip, test_logging.test_config8_ok, and test_random.test_after_fork). * frozenset() is constant, but not a singleton. When run multiple times, the test could fail due to constant interning.
* gh-125041: test_zlib: For s390x HW acceleration, only skip checking the ↵Petr Viktorin2024-10-151-3/+3
| | | | compressed bytes (#125042)
* gh-61698: Use launchctl to detect macOS window manager in tests (#118390)Erlend E. Aasland2024-10-131-15/+9
|
* gh-53203: Improve tests for strptime() (GH-125090)Serhiy Storchaka2024-10-081-4/+49
| | | | | | | | | | Run them with different locales and different date and time. Add the @run_with_locales() decorator to run the test with multiple locales. Improve the run_with_locale() context manager/decorator -- it now catches only expected exceptions and reports the test as skipped if no appropriate locale is available.
* gh-124213: Fix incorrect context manager use in ↵Michał Górny2024-10-021-2/+3
| | | | | | | | | | in_systemd_nspawn_sync_suppressed() (#124892) Fix the incorrect use of `os.open()` result as a context manager, while it is actually a numeric file descriptor. I have missed the problem, because in the original version the `os.open()` call would always fail, and I failed to test the final version in all possible scenarios properly.
* gh-124842: Fix test.support.import_helper.make_legacy_pyc() (GH-124843)Serhiy Storchaka2024-10-011-2/+2
| | | | For source file "path/to/file.py" it created file with incorrect path "/absolute/path/to/path/to/file.pyc" instead of "path/to/file.pyc".
* gh-84559: Change the multiprocessing start method default to `forkserver` ↵Gregory P. Smith2024-09-261-1/+9
| | | | | | | | (GH-101556) Change the default multiprocessing start method away from fork to forkserver or spawn on the remaining platforms where it was fork. See the issue for context. This makes the default far more thread safe (other than for people spawning threads at import time... - don't do that!). Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
* gh-124188: Fix PyErr_ProgramTextObject() (GH-124189)Serhiy Storchaka2024-09-241-3/+7
| | | | | | | | * Detect source file encoding. * Use the "replace" error handler even for UTF-8 (default) encoding. * Remove the BOM. * Fix detection of too long lines if they contain NUL. * Return the head rather than the tail for truncated long lines.
* gh-124213: Skip tests failing inside systemd-nspawn --suppress-sync=true ↵Michał Górny2024-09-201-0/+33
| | | | | | | | | | | | | | (#124215) Add a helper function that checks whether the test suite is running inside a systemd-nspawn container, and skip the few tests failing with `--suppress-sync=true` in that case. The tests are failing because `--suppress-sync=true` stubs out `fsync()`, `fdatasync()` and `msync()` calls, and therefore they always return success without checking for invalid arguments. Call `os.open(__file__, os.O_RDONLY | os.O_SYNC)` and check the errno to detect whether `--suppress-sync=true` is actually used, and skip the tests only in that scenario.
* gh-121039: add Floats/ComplexesAreIdenticalMixin to test.support.testcase ↵Sergey B Kirpichev2024-09-081-0/+40
| | | | (GH-121071)
* gh-101525: Skip test_gdb if the binary is relocated by BOLT. (gh-118572)Donghee Na2024-09-021-0/+9
|
* gh-123142: fix too wide source location of GET_ITER/GET_AITER (#123420)Irit Katriel2024-08-281-1/+4
|
* Revert "GH-120754: Add a strace helper and test set of syscalls for o… ↵Shantanu2024-08-241-166/+0
| | | | | | | (#123303) Revert "GH-120754: Add a strace helper and test set of syscalls for open().read() (#121143)" This reverts commit e38d0afe3548b856ccf0b05c01ed3eefc69cb3e7.
* GH-120754: Add a strace helper and test set of syscalls for open().read() ↵Cody Maloney2024-08-241-0/+166
| | | | (#121143)
* gh-123142: Fix too wide source locations in tracebacks of exceptions from ↵Irit Katriel2024-08-211-1/+15
| | | | broken iterables in comprehensions (#123173)
* gh-117482: Make the Slot Wrapper Inheritance Tests Much More Thorough ↵Eric Snow2024-08-121-9/+133
| | | | | | | | | | (gh-122867) There were a still a number of gaps in the tests, including not looking at all the builtin types and not checking wrappers in subinterpreters that weren't in the main interpreter. This fixes all that. I considered incorporating the names of the PyTypeObject fields (a la gh-122866), but figured doing so doesn't add much value.
* Fix typos in comments and test code (#122846)Xie Yanbo2024-08-123-3/+3
|
* gh-117482: Fix the Slot Wrapper Inheritance Tests (gh-122248)Eric Snow2024-07-291-0/+55
| | | The tests were only checking cases where the slot wrapper was present in the initial case. They were missing when the slot wrapper was added in the additional initializations. This fixes that.
* gh-121275: Fix test_logging and test_smtplib with Python build withoud IPv6 ↵AN Long2024-07-251-1/+2
| | | | | support (#121276) Fix test_logging and test_smtplib with Python build withoud IPv6 support
* gh-120678: pyrepl: Include globals from modules passed with `-i` (GH-120904)Alex Waygood2024-07-171-1/+5
| | | Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* gh-76785: Expand How Interpreter Channels Handle Interpreter Finalization ↵Eric Snow2024-07-153-63/+209
| | | | | (gh-121805) See 6b98b274b6 for an explanation of the problem and solution. Here I've applied the solution to channels.
* gh-76785: Expand How Interpreter Queues Handle Interpreter Finalization ↵Eric Snow2024-07-151-13/+128
| | | | | | | | | | | | | | | | | | | | (gh-116431) Any cross-interpreter mechanism for passing objects between interpreters must be very careful to respect isolation, even when the object is effectively immutable (e.g. int, str). Here this especially relates to when an interpreter sends one of its objects, and then is destroyed while the inter-interpreter machinery (e.g. queue) still holds a reference to the object. When I added interpreters.Queue, I dealt with that case (using an atexit hook) by silently removing all items from the queue that were added by the finalizing interpreter. Later, while working on concurrent.futures.InterpreterPoolExecutor (gh-116430), I noticed it was somewhat surprising when items were silently removed from the queue when the originating interpreter was destroyed. (See my comment on that PR.) It took me a little while to realize what was going on. I expect that users, which much less context than I have, would experience the same pain. My approach, here, to improving the situation is to give users three options: 1. return a singleton (interpreters.queues.UNBOUND) from Queue.get() in place of each removed item 2. raise an exception (interpreters.queues.ItemInterpreterDestroyed) from Queue.get() in place of each removed item 3. existing behavior: silently remove each item (i.e. Queue.get() skips each one) The default will now be (1), but users can still explicitly opt in any of them, including to the silent removal behavior. The behavior for each item may be set with the corresponding Queue.put() call. and a queue-wide default may be set when the queue is created. (This is the same as I did for "synconly".)
* gh-121571: Do not use `EnvironmentError` in tests, use `OSError` instead ↵sobolevn2024-07-101-1/+1
| | | | (#121572)
* Move get_signal_name() to test.support (#121251)Victor Stinner2024-07-022-17/+51
| | | | | | * Move get_signal_name() from test.libregrtest to test.support. * Use get_signal_name() in support.script_helper. * support.script_helper now decodes stdout and stderr from UTF-8, instead of ASCII, if a command failed.
* gh-121016: Add test for `PYTHON_BASIC_REPL` envioronment variable (#121017)devdanzin2024-06-261-0/+6
|
* gh-120417: Add #noqa: F401 to tests (#120627)Victor Stinner2024-06-181-3/+3
| | | | Ignore linter "imported but unused" warnings in tests when the linter doesn't understand how the import is used.
* gh-120417: Remove unused imports in tests (part 1) (#120629)Victor Stinner2024-06-171-1/+0
|
* gh-117398: Add datetime C-API type check test for subinterpreters (gh-119604)neonene2024-06-131-1/+1
| | | Check if the DateTime C-API type matches the datetime.date type on main and shared/isolated subinterpreters.
* gh-119659: Get the datetime CAPI Tests Running Again (gh-120180)Eric Snow2024-06-071-0/+1
| | | | | The tests were accidentally disabled by 2da0dc0, which didn't handle classes correctly. I considered updating no_rerun() to support classes, but the way test_datetime.py works would have made things fairly messy. Plus, it looks like the refleaks we had encountered before have been resolved.
* gh-117657: Fix race involving immortalizing objects (#119927)Sam Gross2024-06-031-2/+2
| | | | | | | | | The free-threaded build currently immortalizes objects that use deferred reference counting (see gh-117783). This typically happens once the first non-main thread is created, but the behavior can be suppressed for tests, in subinterpreters, or during a compile() call. This fixes a race condition involving the tracking of whether the behavior is suppressed.
* CI: set correct working directory for Hypothesis cache (GH-119345)Zac Hatfield-Dodds2024-05-291-0/+7
| | | Set cwd for Hypothesis database
* gh-119659: Move `@no_rerun` to `test.support` (#119660)Nikita Sobolev2024-05-281-0/+19
|
* Remove almost all unpaired backticks in docstrings (#119231)Geoffrey Thomas2024-05-221-7/+7
| | | | | | | | | | | | | | | | | | As reported in #117847 and #115366, an unpaired backtick in a docstring tends to confuse e.g. Sphinx running on subclasses of standard library objects, and the typographic style of using a backtick as an opening quote is no longer in favor. Convert almost all uses of the form The variable `foo' should do xyz to The variable 'foo' should do xyz and also fix up miscellaneous other unpaired backticks (extraneous / missing characters). No functional change is intended here other than in human-readable docstrings.
* gh-118527: Intern code consts in free-threaded build (#118667)Sam Gross2024-05-071-0/+9
| | | | | | We already intern and immortalize most string constants. In the free-threaded build, other constants can be a source of reference count contention because they are shared by all threads running the same code objects.
* gh-117225: Move colorize functionality to own internal module (#118283)Hugo van Kemenade2024-05-011-4/+5
|
* gh-118201: Accomodate flaky behavior of `os.sysconf` on iOS (GH-118453)Russell Keith-Magee2024-05-011-1/+2
|