Skip to content

refactor(testing): deprecate testtools TestCase rebase#2687

Open
l46983284-cpu wants to merge 4 commits into
falconry:masterfrom
l46983284-cpu:fix/deprecate-testtools-testcase-2156
Open

refactor(testing): deprecate testtools TestCase rebase#2687
l46983284-cpu wants to merge 4 commits into
falconry:masterfrom
l46983284-cpu:fix/deprecate-testtools-testcase-2156

Conversation

@l46983284-cpu

@l46983284-cpu l46983284-cpu commented Jul 15, 2026

Copy link
Copy Markdown

Summary of Changes

Deprecate the automatic testtools.TestCase rebase of falcon.testing.TestCase.

When testtools is installed and no custom base is configured, Falcon still uses
testtools.TestCase for compatibility, but now emits DeprecatedWarning once
and points people at unittest / pytest. Full removal is left for Falcon 5.0.

Escape hatch: set FALCON_TESTING_TESTCASE_BASE to an import path
(module:attribute or module.attribute), for example testtools:TestCase or
a project-specific base class.

Docs: FAQ testing section no longer reads like testtools is preferred.
Tests cover default unittest path, implicit testtools deprecation, env override,
and invalid specs.

Assisted by an LLM for the first draft; I reviewed and tested the change before
opening this PR.

Related Issues

Closes #2156

Pull Request Checklist

  • Applied changes to both WSGI and ASGI code paths and interfaces (where applicable).
  • Added tests for changed code.
  • Performed automated tests and code quality checks by running tox.
  • Prefixed code comments with GitHub nick and an appropriate prefix.
  • Coding style is consistent with the rest of the framework.
  • Updated documentation for changed code.
    • Added docstrings for any new classes, functions, or modules.
    • Updated docstrings for any modifications to existing code.
    • Updated both WSGI and ASGI docs (where applicable).
    • Added references to new classes, functions, or modules to the relevant RST file under docs/.
    • Updated all relevant supporting documentation files under docs/.
    • A copyright notice is included at the top of any new modules (using your own name or the name of your organization).
    • Changed/added classes/methods/functions have appropriate versionadded, versionchanged, or deprecated directives.
  • Changes (and possible deprecations) have towncrier news fragments under docs/_newsfragments/, with the file name format {issue_number}.{fragment_type}.rst. (Run tox -e towncrier, and inspect docs/_build/html/changes/ in the browser to ensure it renders correctly.)
  • LLM output, if any, has been carefully reviewed and tested by a human developer. (See also: Use of LLMs ("AI").)

@l46983284-cpu
l46983284-cpu force-pushed the fix/deprecate-testtools-testcase-2156 branch 2 times, most recently from 8a14a30 to 877ef0a Compare July 18, 2026 08:42
@l46983284-cpu

Copy link
Copy Markdown
Author

Rebased onto current master. Product unit is unchanged: deprecate silent testtools.TestCase rebase of falcon.testing.TestCase with docs/tests/towncrier fragment.

Local: python3 -m py_compile on falcon/testing/test_case.py and tests/test_testcase_base.py.

@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.47368% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.03%. Comparing base (9902b95) to head (8c972ec).

Files with missing lines Patch % Lines
falcon/testing/test_case.py 89.47% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##            master    #2687      +/-   ##
===========================================
- Coverage   100.00%   97.03%   -2.97%     
===========================================
  Files           64       64              
  Lines         7987     8021      +34     
  Branches      1105     1112       +7     
===========================================
- Hits          7987     7783     -204     
- Misses           0      204     +204     
- Partials         0       34      +34     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Emit DeprecatedWarning when falcon.testing.TestCase auto-rebases onto
testtools, add FALCON_TESTING_TESTCASE_BASE escape hatch, and document
unittest/pytest as the preferred path until Falcon 5.0 removes the
integration.

Closes falconry#2156

Signed-off-by: Alex Chen <l46983284@gmail.com>
Apply ruff import order/line length and document the deprecation with a
versionchanged directive on TestCase.

Signed-off-by: Alex Chen <l46983284@gmail.com>
mypy --strict rejects a runtime-resolved base class variable as a type
even with type: ignore[misc]; cover valid-type for the deprecation path.

Signed-off-by: Alex Chen <l46983284@gmail.com>
@l46983284-cpu
l46983284-cpu force-pushed the fix/deprecate-testtools-testcase-2156 branch from ad00923 to 8c972ec Compare July 21, 2026 11:04
@l46983284-cpu

Copy link
Copy Markdown
Author

Pushed a typing fix for the CI mypy jobs: the runtime-resolved _UnittestBase needs type: ignore[misc, valid-type], not only misc.

tox -e mypy / local mypy --strict falcon are clean on this head, and the deprecation tests still pass. The macOS py312_nocover helpers attribute failure looks unrelated to this unit; happy to dig if it still shows on the new head.

Expand TestCase type: ignore for runtime-selected base class and keep
falcon.testing.helpers importable under installed layouts used by CI.

Signed-off-by: Alex Chen <l46983284@gmail.com>
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.

Deprecate testtools support

1 participant