From: Zsolt Dollenstein Date: Tue, 13 Aug 2019 15:26:01 +0000 (+0200) Subject: [blackd] Support `py36`-style values in X-Python-Variant header (#979) X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/40e8b3a231bade22d838858435a33d60a8325306 [blackd] Support `py36`-style values in X-Python-Variant header (#979) --- diff --git a/blackd.py b/blackd.py index 25a9a15..37fcec3 100644 --- a/blackd.py +++ b/blackd.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): diff --git a/tests/test_black.py b/tests/test_black.py index ce84037..3b37011 100644 --- a/tests/test_black.py +++ b/tests/test_black.py @@ -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")