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

fix: explicitly export the items in the falcon.testing namespace #2388

Merged
merged 3 commits into from
Oct 24, 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
7 changes: 7 additions & 0 deletions docs/_newsfragments/2387.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Running mypy on code that uses parts of ``falcon.testing`` naively
would lead to errors like::

Name "falcon.testing.TestClient" is not defined

This has been fixed by explicitly exporting the names that are
imported in the ``falcon.testing`` namespace.
46 changes: 45 additions & 1 deletion falcon/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,50 @@ def test_get_message(client):
from falcon.testing.srmock import StartResponseMock
from falcon.testing.test_case import TestCase

__all__ = (
# client
'ASGIConductor',
'Cookie',
'Result',
'ResultBodyStream',
'simulate_delete',
'simulate_get',
'simulate_head',
'simulate_options',
'simulate_patch',
'simulate_post',
'simulate_put',
'simulate_request',
'StreamedResult',
'TestClient',
# helpers
'ASGILifespanEventEmitter',
'ASGIRequestEventEmitter',
'ASGIResponseEventCollector',
'ASGIWebSocketSimulator',
'closed_wsgi_iterable',
'create_asgi_req',
'create_environ',
'create_req',
'create_scope',
'create_scofrom_headers',
'get_unused_port',
'rand_string',
'redirected',
# resource
'capture_responder_args',
'capture_responder_args_async',
'set_resp_defaults',
'set_resp_defaults_async',
'SimpleTestResource',
'SimpleTestResourceAsync',
# srmock
'StartResponseMock',
# test_case
'TestCase',
)


# NOTE(kgriffs): Alias for backwards-compatibility with Falcon 0.2
# TODO: remove in falcon 4
# TODO(vytas): Remove in Falcon 5.0.
httpnow = _util.http_now