Content-Length: 318824 | pFad | http://github.com/datalad/datalad/pull/7690/files

C6 test: refactor test_parallel.py to be abit more pytest'y by yarikoptic · Pull Request #7690 · datalad/datalad · GitHub
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: refactor test_parallel.py to be abit more pytest'y #7690

Merged
merged 3 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog.d/pr-7690.md
Original file line number Diff line number Diff line change
@@ -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))
27 changes: 11 additions & 16 deletions datalad/support/tests/test_parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,23 @@
assert_greater_equal,
assert_raises,
assert_repo_status,
known_failure_osx,
on_osx,
on_windows,
rmtree,
skip_if,
slow,
with_tempfile,
)

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
Expand Down Expand Up @@ -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):
Expand All @@ -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
Expand All @@ -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):
Expand Down
Loading








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/datalad/datalad/pull/7690/files

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy