Skip to content

Commit

Permalink
fix: explicitly export the items in the falcon.testing namespace
Browse files Browse the repository at this point in the history
... so mypy also likes it when falcon.testing.TestClient is used
  • Loading branch information
jap committed Oct 24, 2024
1 parent 4d04e9b commit aa39c32
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
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.
44 changes: 44 additions & 0 deletions 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
httpnow = _util.http_now

0 comments on commit aa39c32

Please sign in to comment.