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

tests: ignore coverage on helper test functions #980

Merged
merged 6 commits into from
May 28, 2021
Merged

tests: ignore coverage on helper test functions #980

merged 6 commits into from
May 28, 2021

Conversation

Kludex
Copy link
Member

@Kludex Kludex commented Mar 7, 2021

I'll open several issues for #102

I don't think a single PR will be a good thing to do, but I can merge them in a single one if you think is the best.

@Kludex Kludex changed the title tests: full coverage tests: ignore coverage on helper test functions Mar 7, 2021
@Kludex Kludex marked this pull request as ready for review March 7, 2021 17:37
@@ -159,7 +159,7 @@ def test_ssl_config_combined(tls_certificate_pem_path):
assert config.is_ssl is True


def asgi2_app(scope):
def asgi2_app(scope): # pragma: no cover
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should not be skipped imho, we have code in config.py that makes the switch from asgi2 to asgi3 :

uvicorn/uvicorn/config.py

Lines 331 to 339 in d81b96e

if self.interface == "auto":
if inspect.isclass(self.loaded_app):
use_asgi_3 = hasattr(self.loaded_app, "__await__")
elif inspect.isfunction(self.loaded_app):
use_asgi_3 = asyncio.iscoroutinefunction(self.loaded_app)
else:
call = getattr(self.loaded_app, "__call__", None)
use_asgi_3 = asyncio.iscoroutinefunction(call)
self.interface = "asgi3" if use_asgi_3 else "asgi2"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. But the body of that function is not executed, because the __call__ on the ASGI2Middleware is never reached.

async def __call__(self, scope, receive, send):
instance = self.app(scope)
await instance(receive, send)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated and I'm now adding "pragma" on the exact lines that are needed. What do you think? @euri10

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm thanks !

tests/supervisors/test_reload.py Outdated Show resolved Hide resolved
tests/supervisors/test_multiprocess.py Outdated Show resolved Hide resolved
@Kludex Kludex added the testing label May 28, 2021
@euri10 euri10 self-requested a review May 28, 2021 17:25
@euri10 euri10 merged commit abde790 into encode:master May 28, 2021
Kludex added a commit to sephioh/uvicorn that referenced this pull request Oct 29, 2022
* tests: ignore test lines

* Update tests/supervisors/test_reload.py

Co-authored-by: euri10 <[email protected]>

* Update tests/supervisors/test_multiprocess.py

Co-authored-by: euri10 <[email protected]>

* precision on pragmas

Co-authored-by: euri10 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants