vinissimus / async-asgi-testclient

A framework-agnostic library for testing ASGI web applications
MIT License
159 stars 20 forks source link

Remove default dict for self.cookies attr #30

Closed otsuka closed 4 years ago

otsuka commented 4 years ago

In WebSocketSession.connect() method, check if self.cookies is None to use TestClient.cookie_jar. But self.cookies is never be None because the line self.cookies = cookies or {} exists in its constructor.

codecov-io commented 4 years ago

Codecov Report

Merging #30 into master will increase coverage by 0.25%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #30      +/-   ##
==========================================
+ Coverage   85.89%   86.14%   +0.25%     
==========================================
  Files           6        6              
  Lines         397      397              
==========================================
+ Hits          341      342       +1     
+ Misses         56       55       -1
Impacted Files Coverage Δ
async_asgi_testclient/websocket.py 68.29% <100%> (+1.21%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2140474...cd1b1b2. Read the comment docs.

masipcat commented 4 years ago

Can you add a test for this use-case?

otsuka commented 4 years ago

I added a test.

otsuka commented 4 years ago

BTW, you give a float value to the timeout parameter of TestClient in test code,

async with TestClient(starlette_app, timeout=0.1) as client:

but the TestClient's timeout parameter type is defined as int

    def __init__(
        self,
        application,
        use_cookies: bool = True,
        timeout: Optional[int] = None,
        headers: Optional[Union[dict, CIMultiDict]] = None,
        scope: Optional[dict] = None,
    ):
masipcat commented 4 years ago

Hmm, you are right. I'll fix it!

masipcat commented 4 years ago

Released 1.4.2 with the annotation fix