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)) diff --git a/datalad/support/tests/test_parallel.py b/datalad/support/tests/test_parallel.py index ff7c925606..d93210ebf0 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, ) @@ -45,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 @@ -74,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): @@ -87,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 @@ -100,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):