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

Update test_black.shhh_click test for click 8+ #2993

Merged
merged 1 commit into from
Apr 5, 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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ repos:
- types-PyYAML
- tomli >= 0.2.6, < 2.0.0
- types-typed-ast >= 1.4.1
- click >= 8.0.0
- click >= 8.1.0
- platformdirs >= 2.1.0

- repo: https://github.com/pre-commit/mirrors-prettier
Expand Down
10 changes: 6 additions & 4 deletions tests/test_black.py
Original file line number Diff line number Diff line change
Expand Up @@ -1256,23 +1256,25 @@ def test_assert_equivalent_different_asts(self) -> None:

def test_shhh_click(self) -> None:
try:
from click import _unicodefun
from click import _unicodefun # type: ignore
except ImportError:
self.skipTest("Incompatible Click version")
if not hasattr(_unicodefun, "_verify_python3_env"):

if not hasattr(_unicodefun, "_verify_python_env"):
self.skipTest("Incompatible Click version")

# First, let's see if Click is crashing with a preferred ASCII charset.
with patch("locale.getpreferredencoding") as gpe:
gpe.return_value = "ASCII"
with self.assertRaises(RuntimeError):
_unicodefun._verify_python3_env() # type: ignore
_unicodefun._verify_python_env()
# Now, let's silence Click...
black.patch_click()
# ...and confirm it's silent.
with patch("locale.getpreferredencoding") as gpe:
gpe.return_value = "ASCII"
try:
_unicodefun._verify_python3_env() # type: ignore
_unicodefun._verify_python_env()
except RuntimeError as re:
self.fail(f"`patch_click()` failed, exception still raised: {re}")

Expand Down