Update test_black.shhh_click test for click 8+ (#2993)
The 8.0.x series renamed its "die on LANG=C" function and the 8.1.x series straight up deleted it. Unfortunately this makes this test type check cleanly hard, so we'll just lint with click 8.1+ (the pre-commit hook configuration was changed mostly to just evict any now unsupported mypy environments)
This commit is contained in:
parent
24c708eb37
commit
fa5fd262ff
@ -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
|
||||
|
@ -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}")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user