Skip to content

Commit

Permalink
Some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ahopkins committed Dec 31, 2023
1 parent c6f147f commit e3a61b2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
8 changes: 2 additions & 6 deletions sanic_testing/reusable.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ def _sanic_endpoint_test(

if gather_request:
_collect_request = partial(self._collect_request, request_data)
self.app.request_middleware.appendleft( # type: ignore
_collect_request
)
self.app.request_middleware.appendleft(_collect_request) # type: ignore # noqa

for route in self.app.router.routes:
if _collect_request not in route.extra.request_middleware:
Expand All @@ -137,9 +135,7 @@ def _sanic_endpoint_test(
)

try:
self.app.request_middleware.remove( # type: ignore
_collect_request
)
self.app.request_middleware.remove(_collect_request) # type: ignore # noqa
except BaseException: # noqa
pass

Expand Down
12 changes: 4 additions & 8 deletions sanic_testing/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,7 @@ def _sanic_endpoint_test(
self.app.signal_router.reset()

if gather_request:
self.app.request_middleware.appendleft( # type: ignore
_collect_request
)
self.app.request_middleware.appendleft(_collect_request) # type: ignore # noqa

try:
self.app.exception(MethodNotSupported)(self._error_handler)
Expand Down Expand Up @@ -246,9 +244,7 @@ def _sanic_endpoint_test(

if gather_request:
try:
self.app.request_middleware.remove( # type: ignore
_collect_request
)
self.app.request_middleware.remove(_collect_request) # type: ignore # noqa
except BaseException: # noqa
pass

Expand Down Expand Up @@ -388,8 +384,8 @@ async def request( # type: ignore
url = f"{scheme}://{ASGI_HOST}:{ASGI_PORT}{url}"

if self._collect_request not in self.sanic_app.request_middleware:
self.sanic_app.request_middleware.appendleft( # type: ignore
self._collect_request
self.sanic_app.request_middleware.appendleft(
self._collect_request # type: ignore
)

self.gather_request = gather_request
Expand Down

0 comments on commit e3a61b2

Please sign in to comment.