cpython/Lib/test/test_importlib
Victor Stinner 1d032ea3d6
[3.12] gh-109974: Fix threading lock_tests race conditions (#110057) (#110346)
* gh-109974: Fix threading lock_tests race conditions (#110057)

Fix race conditions in test_threading lock tests. Wait until a
condition is met rather than using time.sleep() with a hardcoded
number of seconds.

* Replace sleeping loops with support.sleeping_retry() which raises
  an exception on timeout.
* Add wait_threads_blocked(nthread) which computes a sleep depending
  on the number of threads. Remove _wait() function.
* test_set_and_clear(): use a way longer Event.wait() timeout.
* BarrierTests.test_repr(): wait until the 2 threads are waiting for
  the barrier. Use a way longer timeout for Barrier.wait() timeout.
* test_thread_leak() no longer needs to count
  len(threading.enumerate()): Bunch uses
  threading_helper.wait_threads_exit() internally which does it in
  wait_for_finished().
* Add BaseLockTests.wait_phase() which implements a timeout.
  test_reacquire() and test_recursion_count() use wait_phase().

(cherry picked from commit 4e356ad183)

* gh-109974: Fix more threading lock_tests race conditions (#110089)

* Add context manager on Bunch class.
* Bunch now catchs exceptions on executed functions and re-raise them
  at __exit__() as an ExceptionGroup.
* Rewrite BarrierProxy.test_default_timeout(). Use a single thread.
  Only check that barrier.wait() blocks for at least default timeout
  seconds.
* test_with(): inline _with() function.

(cherry picked from commit 743e3572ee)
2023-10-04 11:26:45 +00:00
..
builtin gh-98040: Remove find_loader, find_module and other deprecated APIs (#98059) 2023-05-03 04:55:22 -07:00
data
extension gh-103247: clear the module cache in a test in test_importlib/extensions/test_loader.py (GH-104226) 2023-05-10 00:59:04 +00:00
frozen gh-98040: Remove find_loader, find_module and other deprecated APIs (#98059) 2023-05-03 04:55:22 -07:00
import_ gh-98040: Remove find_loader, find_module and other deprecated APIs (#98059) 2023-05-03 04:55:22 -07:00
namespace_pkgs
partial
resources
source gh-98040: Remove find_loader, find_module and other deprecated APIs (#98059) 2023-05-03 04:55:22 -07:00
__init__.py
__main__.py
_context.py
_path.py
abc.py
fixtures.py gh-98040: Remove find_loader, find_module and other deprecated APIs (#98059) 2023-05-03 04:55:22 -07:00
stubs.py
test_abc.py gh-98040: Remove find_loader, find_module and other deprecated APIs (#98059) 2023-05-03 04:55:22 -07:00
test_api.py gh-98040: Remove find_loader, find_module and other deprecated APIs (#98059) 2023-05-03 04:55:22 -07:00
test_lazy.py
test_locks.py [3.12] gh-109974: Fix threading lock_tests race conditions (#110057) (#110346) 2023-10-04 11:26:45 +00:00
test_main.py [3.12] gh-106300: Improve assertRaises(Exception) usages in tests (GH-106302) (GH-106534) 2023-07-07 14:25:24 -07:00
test_metadata_api.py
test_namespace_pkgs.py
test_pkg_import.py
test_spec.py
test_threaded_import.py [3.12] Fix test_importlib.test_side_effect_import() (GH-104840) (#104842) 2023-05-25 02:36:13 +02:00
test_util.py [3.12] Update the expected bytecode magic in test_importlib.test_util (#107626) 2023-08-04 13:41:03 +00:00
test_windows.py gh-98040: Remove find_loader, find_module and other deprecated APIs (#98059) 2023-05-03 04:55:22 -07:00
test_zip.py
threaded_import_hangers.py
util.py gh-98040: Remove find_loader, find_module and other deprecated APIs (#98059) 2023-05-03 04:55:22 -07:00