-
-
Notifications
You must be signed in to change notification settings - Fork 906
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Paweł Rubin
committed
Dec 20, 2023
1 parent
0d36db7
commit 7b26974
Showing
5 changed files
with
32 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
from starlette.middleware import Middleware | ||
from starlette.types import ASGIApp | ||
from starlette.types import ASGIApp, Receive, Scope, Send | ||
|
||
|
||
class CustomMiddleware: | ||
def __init__(self, app: ASGIApp, foo: str, *, bar: int) -> None: # pragma: no cover | ||
class CustomMiddleware: # pragma: no cover | ||
def __init__(self, app: ASGIApp, foo: str, *, bar: int) -> None: | ||
self.app = app | ||
self.foo = foo | ||
self.bar = bar | ||
|
||
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: | ||
await self.app(scope, receive, send) | ||
|
||
def test_middleware_repr(): | ||
|
||
def test_middleware_repr() -> None: | ||
middleware = Middleware(CustomMiddleware, "foo", bar=123) | ||
assert repr(middleware) == "Middleware(CustomMiddleware, 'foo', bar=123)" | ||
|
||
|
||
def test_middleware_iter(): | ||
def test_middleware_iter() -> None: | ||
cls, args, kwargs = Middleware(CustomMiddleware, "foo", bar=123) | ||
assert (cls, args, kwargs) == (CustomMiddleware, ("foo",), {"bar": 123}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters