Skip to content

Commit

Permalink
lint, coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
mattip committed Nov 10, 2022
1 parent d431642 commit f792f80
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
7 changes: 4 additions & 3 deletions packaging/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,13 @@ def _generic_abi() -> List[str]:
# - linux: '.cpython-310-x86_64-linux-gnu.so' => cp310
# - mac: '.cpython-310-darwin.so' => cp310
# - win: '.cp310-win_amd64.pyd' => cp310
# - pypy: '.pypy38-pp73-x86_64-linux-gnu.so' => pypy38-pp73
# - pypy: '.pypy38-pp73-x86_64-linux-gnu.so' => pypy38_pp73
# - graalpy: '.graalpy-38-native-x86_64-darwin.dylib'
# => graalpy-38-native
# => graalpy_38_native

ext_suffix = _get_config_var("EXT_SUFFIX", warn=True)
assert ext_suffix[0] == "."
if not isinstance(ext_suffix, str) or ext_suffix[0] != ".":
raise SystemError("invalid sysconfig.get_config_var('EXT_SUFFIX')")
_, soabi, ext = ext_suffix.split(".")
if soabi.startswith("cpython"):
abi = "cp" + soabi.split("-")[1]
Expand Down
18 changes: 17 additions & 1 deletion tests/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,9 +845,25 @@ def test__generic_abi_linux_cpython(self, monkeypatch):
def test__generic_abi_jp(self, monkeypatch):
config = {"EXT_SUFFIX": ".return exactly this.so"}
monkeypatch.setattr(sysconfig, "get_config_var", config.__getitem__)
monkeypatch.setattr(tags, "interpreter_name", lambda: "other")
assert tags._generic_abi() == ["return exactly this"]

def test__generic_abi_graal(self, monkeypatch):
config = {"EXT_SUFFIX": ".graalpy-38-native-x86_64-darwin.so"}
monkeypatch.setattr(sysconfig, "get_config_var", config.__getitem__)
assert tags._generic_abi() == ["graalpy_38_native"]

def test__generic_abi_none(self, monkeypatch):
config = {"EXT_SUFFIX": "..so"}
monkeypatch.setattr(sysconfig, "get_config_var", config.__getitem__)
assert tags._generic_abi() == []

def test__generic_abi_none(self, monkeypatch):
config = {"EXT_SUFFIX": "invalid"}
monkeypatch.setattr(sysconfig, "get_config_var", config.__getitem__)
with pytest.raises(SystemError) as e:
tags._generic_abi()
assert "EXT_SUFFIX" in str(e.value)

def test__generic_abi_linux_pypy(self, monkeypatch):
# issue gh-606
config = {
Expand Down

0 comments on commit f792f80

Please sign in to comment.