Skip to content

Add atomic coverage tests for cloudpickle_fast and is_tornado_coroutine - #625

Open
zheng-guannan577 wants to merge 2 commits into
cloudpipe:masterfrom
zheng-guannan577:test-346-atomic-coverage
Open

zheng-guannan577 wants to merge 2 commits into
cloudpipe:masterfrom
zheng-guannan577:test-346-atomic-coverage

Conversation

@zheng-guannan577

Copy link
Copy Markdown

Closes #346 (in part — this PR covers two small, self-contained spots; more atomic PRs can follow for the remaining uncovered sections).

What this PR adds

Measured with a fresh local coverage run (Python 3.12, pytest tests/cloudpickle_test.py tests/cloudpickle_file_test.py tests/test_backward_compat.py), total coverage goes from 88% to 89%. Two uncovered spots, each with its own topical tests:

  1. cloudpickle/cloudpickle_fast.py — 0% → 100% (tests/test_backward_compat.py)

    • test_cloudpickle_fast_forwards_public_names: CloudPickler, Pickler, dumps and loads accessed through cloudpickle_fast are the very same objects as on cloudpickle (PEP 562 __getattr__ forwarding for pickles generated by previous cloudpickle versions).
    • test_cloudpickle_fast_unknown_attribute_raises_attribute_error: accessing an unknown attribute still raises AttributeError.
    • The module's own docstring points at tests/test_backward_compat.py, but no test had ever exercised it.
  2. is_tornado_coroutine False branches (cloudpickle/cloudpickle.py:463, 467, tests/cloudpickle_test.py)

    • test_is_tornado_coroutine_without_tornado_gen: returns False when tornado.gen was never imported (monkeypatch.delitem(sys.modules, "tornado.gen")).
    • test_is_tornado_coroutine_with_old_tornado: returns False when tornado.gen exists but has no is_coroutine_function (stub module simulating an old Tornado).
    • Both assert the function still emits its DeprecationWarning. The existing test_tornado_coroutine only covers the True path.

What this PR does not do

  • No production code is changed (tests only, +42 lines).
  • No other uncovered sections are touched (e.g. the pure-Python Pickler fallback and the nogil/co_nmeta branches, which cannot be exercised on CPython 3.12 — left for follow-up atomic PRs if desired).

Verification

  • New tests: 4 passed.
  • Full suite: 266 passed, 10 skipped, 2 xfailed (baseline was 262 passed with the same skips/xfails — no regressions).
  • git diff --check clean; no new ruff findings on the touched files (repo baseline has pre-existing findings, unchanged by this PR).

Disclosure

This PR was drafted with AI assistance and verified locally by running the test suite and coverage as described above. No maintainer endorsement is claimed or implied.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Increase test coverage

1 participant