Skip to content

test(django): Remove dead code and stale markers from the Django test suite - #7156

Draft
ericapisani wants to merge 4 commits into
masterfrom
ep/django-tests-hygiene
Draft

test(django): Remove dead code and stale markers from the Django test suite#7156
ericapisani wants to merge 4 commits into
masterfrom
ep/django-tests-hygiene

Conversation

@ericapisani

@ericapisani ericapisani commented Aug 10, 2026

Copy link
Copy Markdown
Member

Description

Cleanup pass over the Django test suite, no change in what is covered:

  • stale xfail on test_read_request (the test passes — it currently reports as xpass)
  • spurious django_db marker on test_response_trace
  • dead rest_hello view and its URL entry in the test app
  • unused client fixture argument on 7 test signatures

First of four PRs trimming redundancy from this suite (391 -> 312 cases overall). This one doesn't change this, is a cleanup PR.

Refs PY-2641
Refs #6975

The marker was added in 2019 (6326cb6) with no reason or issue
reference, and the test now XPASSes across the supported Django range
(verified 5.2.16 and 6.x; the already-read-body handling it exercises
is stable Django public-contract behavior). A non-strict xfail that
always passes can never fail the build, so the test was dead weight
that would have silently xpassed a real regression. Removing the
marker restores it as a genuine regression guard.
No test references rest_hello (its test was removed in a 2019-era
revert cycle); every other registered URL is exercised by the suite.
Empirical audit of all 61 django_db-marked tests in the django suite:
60 are load-bearing (DB queries, login, or session-cookie loads via
SessionMiddleware). The cache tests' markers also stay: stripping them
broke a pytest-forked x pytest-django teardown invariant. This test is
the only one that is genuinely DB-free (DRF view with no ORM work, no
session cookie sent) and safe to unmark.
AST-verified unused: capture_events in test_materialized_user_captured
(never called), client in 6 raw-cursor executemany tests (no HTTP).
Unrequested fixtures are never built, so removal is behavior-neutral;
signatures now truthfully describe each test's dependencies.
@ericapisani ericapisani changed the title ep/django tests hygiene test(django): Remove dead code and stale markers from the Django test suite Aug 10, 2026
@linear-code

linear-code Bot commented Aug 10, 2026

Copy link
Copy Markdown

PY-2641

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

103984 passed | ⏭️ 6677 skipped | Total: 110661 | Pass Rate: 93.97% | Execution Time: 360m 51s

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 2485 uncovered lines.
❌ Project coverage is 90.12%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    90.15%    90.12%    -0.03%
==========================================
  Files          193       193         —
  Lines        25147     25147         —
  Branches      9136      9136         —
==========================================
+ Hits         22669     22662        -7
- Misses        2478      2485        +7
- Partials      1431      1431         —

Generated by Codecov Action

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.

1 participant