From 03cdb4a12268b5017070fe71b813d90db8dcf34d Mon Sep 17 00:00:00 2001 From: Mayowa Pitan Date: Mon, 26 Oct 2026 02:28:20 +0100 Subject: [PATCH 1/4] Fix Python 3.14 timeout compatibility and assertion reporting --- README.md | 34 ++++ codewars_test/test_framework.py | 76 +++++++- tests/fixtures/expect_error_sample.py | 3 +- tests/test_compatibility.py | 261 ++++++++++++++++++++++++++ tests/test_outputs.py | 13 +- 5 files changed, 373 insertions(+), 14 deletions(-) create mode 100644 tests/test_compatibility.py diff --git a/README.md b/README.md index 1df2030..b57174c 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,40 @@ def example_tests(): test.assert_equals(add(1, 1), 2, 'Optional Message on Failure') ``` +### Assertion control flow and timeouts + +Assertions report a failure and continue by default. With `allow_raise=True`, +the assertion stops the current decorated block and reports its failure once. +The enclosing `it` or `describe` still closes normally, and its `after` hook +runs. At top level, the framework's assertion exception still propagates. + +`@test.timeout(seconds)` executes immediately in a child process. On the +Codewars Linux runtime it uses a local `fork` context so existing nested test +functions work on Python 3.14 without changing the process-wide start method. +Normal completion retains the existing additional passing assertion. An expired +timeout, abnormal exit or exit before the wrapper completes reports a failure; +timed-out children are terminated and joined, including children that ignore +`SIGTERM`. Previously printed assertions remain visible. + +The fork context preserves the existing Linux execution model. Tests that start +threads or import libraries with background threads still require validation in +the full runner image. This compatibility change does not make fork safe for +arbitrary multithreaded programs. + +### Development tests + +Run the output fixtures and compatibility tests with the interpreter under test: + +```bash +python -m unittest discover -v +``` + +The timeout regression tests run on Linux and check success/failure counts, +nested functions, unchanged global start-method selection, early exits, signals, +startup errors, child cleanup and `allow_raise` behavior. Other platforms skip +these Linux-specific checks. Set `CW10_RESULTS` to a writable JSON file path to +capture their raw outputs for integration checks with the Exo result parser. +