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

Keep tests working w/ upcoming aiohttp 4.0.0 #2974

Merged
merged 1 commit into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ warn_unreachable=True
disallow_untyped_defs=True
check_untyped_defs=True

# No incremental mode
cache_dir=/dev/null

[mypy-black]
# The following is because of `patch_click()`. Remove when
# we drop Python 3.6 support.
Expand Down
15 changes: 11 additions & 4 deletions tests/test_blackd.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import re
from typing import Any
from unittest.mock import patch

from click.testing import CliRunner
Expand All @@ -8,12 +9,18 @@

try:
import blackd
from aiohttp.test_utils import AioHTTPTestCase, unittest_run_loop
from aiohttp.test_utils import AioHTTPTestCase
from aiohttp import web
except ImportError as e:
raise RuntimeError("Please install Black with the 'd' extra") from e
Comment on lines +14 to +15
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The old has_blackd_deps logic was doing absolutely nothing useful so instead let's error out with an informative exception.


try:
from aiohttp.test_utils import unittest_run_loop
except ImportError:
has_blackd_deps = False
else:
has_blackd_deps = True
# unittest_run_loop is unnecessary and a no-op since aiohttp 3.8, and aiohttp 4
# removed it. To maintain compatibility we can make our own no-op decorator.
def unittest_run_loop(func: Any, *args: Any, **kwargs: Any) -> Any:
return func


@pytest.mark.blackd
Expand Down