From 9a0db8e6209a9aa0c4c134e8706c881c07dfd08f Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Thu, 12 Dec 2024 11:50:06 -0500 Subject: [PATCH 1/3] chore: remove unused imports --- datalad/support/tests/test_parallel.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/datalad/support/tests/test_parallel.py b/datalad/support/tests/test_parallel.py index ff7c925606..c713062bc3 100644 --- a/datalad/support/tests/test_parallel.py +++ b/datalad/support/tests/test_parallel.py @@ -33,11 +33,7 @@ assert_greater_equal, assert_raises, assert_repo_status, - known_failure_osx, - on_osx, - on_windows, rmtree, - skip_if, slow, with_tempfile, ) From b9675f85a790342e865d38b07be09fc3f51efa21 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Thu, 12 Dec 2024 12:22:36 -0500 Subject: [PATCH 2/3] test: refactor test_ProducerConsumer to use fixture and parametrization --- datalad/support/tests/test_parallel.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/datalad/support/tests/test_parallel.py b/datalad/support/tests/test_parallel.py index c713062bc3..d93210ebf0 100644 --- a/datalad/support/tests/test_parallel.py +++ b/datalad/support/tests/test_parallel.py @@ -41,7 +41,15 @@ info_log_level = lgr.getEffectiveLevel() >= logging.INFO -def check_ProducerConsumer(PC, jobs): +@pytest.fixture(params=["auto", None, 1, 10]) +def jobs(request): + """Fixture to automagically sweep over a sample of "jobs" values + """ + return request.param + + +@pytest.mark.parametrize("PC", [ProducerConsumer, ProducerConsumerProgressLog]) +def test_ProducerConsumer_PC(PC, jobs): def slowprod(n, secs=0.001): for i in range(n): yield i @@ -70,7 +78,7 @@ def fastcons(i): [{"i": i, "status": "ok" if i % 2 else "error"} for i in range(10)]) -def check_producing_consumer(jobs): +def test_producing_consumer(jobs): def producer(): yield from range(3) def consumer(i): @@ -83,7 +91,7 @@ def consumer(i): assert_equal(list(pc), [0, 1, 2, "0", "1", "4"]) -def check_producer_future_key(jobs): +def test_producer_future_key(jobs): def producer(): for i in range(3): yield i, {"k": i**2} # dict is mutable, will need a key @@ -96,15 +104,6 @@ def consumer(args): assert_equal(list(pc), [0, 1, 2]) -def test_ProducerConsumer(): - # Largely a smoke test, which only verifies correct results output - for jobs in "auto", None, 1, 10: - for PC in ProducerConsumer, ProducerConsumerProgressLog: - check_ProducerConsumer(PC, jobs) - check_producing_consumer(jobs) - check_producer_future_key(jobs) - - @slow # 12sec on Yarik's laptop @with_tempfile(mkdir=True) def test_creatsubdatasets(topds_path=None, n=2): From 52175925c3ca3599b2baa351572ee56dc2a59c2c Mon Sep 17 00:00:00 2001 From: DataLad Bot Date: Fri, 13 Dec 2024 15:25:47 +0000 Subject: [PATCH 3/3] [release-action] Autogenerate changelog snippet for PR 7690 --- changelog.d/pr-7690.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelog.d/pr-7690.md diff --git a/changelog.d/pr-7690.md b/changelog.d/pr-7690.md new file mode 100644 index 0000000000..a21442855c --- /dev/null +++ b/changelog.d/pr-7690.md @@ -0,0 +1,3 @@ +### 🧪 Tests + +- test: refactor test_parallel.py to be abit more pytest'y. [PR #7690](https://github.com/datalad/datalad/pull/7690) (by [@yarikoptic](https://github.com/yarikoptic))