Skip to content
Permalink
Browse files

[blackd] Support `py36`-style values in X-Python-Variant header (#979)

  • Loading branch information...
zsol authored and JelleZijlstra committed Aug 13, 2019
1 parent bd0ab3c commit 40e8b3a231bade22d838858435a33d60a8325306
Showing with 13 additions and 2 deletions.
  1. +5 −1 blackd.py
  2. +8 −1 tests/test_black.py
@@ -129,7 +129,11 @@ def parse_python_variant_header(value: str) -> Tuple[bool, Set[black.TargetVersi
for version in value.split(","):
if version.startswith("py"):
version = version[len("py") :]
major_str, *rest = version.split(".")
if "." in version:
major_str, *rest = version.split(".")
else:
major_str = version[0]
rest = [version[1:]] if len(version) > 1 else []
try:
major = int(major_str)
if major not in (2, 3):
@@ -1624,18 +1624,25 @@ class BlackDTestCase(AioHTTPTestCase):
response = await self.client.post(
"/", data=code, headers={blackd.PYTHON_VARIANT_HEADER: header_value}
)
self.assertEqual(response.status, expected_status)
self.assertEqual(
response.status, expected_status, msg=await response.text()
)

await check("3.6", 200)
await check("py3.6", 200)
await check("3.6,3.7", 200)
await check("3.6,py3.7", 200)
await check("py36,py37", 200)
await check("36", 200)
await check("3.6.4", 200)

await check("2", 204)
await check("2.7", 204)
await check("py2.7", 204)
await check("3.4", 204)
await check("py3.4", 204)
await check("py34,py36", 204)
await check("34", 204)

@skip_if_exception("ClientOSError")
@unittest.skipUnless(has_blackd_deps, "blackd's dependencies are not installed")

0 comments on commit 40e8b3a

Please sign in to comment.
You can’t perform that action at this time.