Skip to content

Commit c97b412

Browse files
committed
fixup! EAPI: add functionality for handling PMS eapis
1 parent 2f09b8a commit c97b412

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/pkgcore/ebuild/eapi.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,8 @@ def bash_libs(self):
378378
)
379379
except (IOError, subprocess.CalledProcessError) as e:
380380
raise Exception(
381-
f"failed to generate EAPI '{self}' global lib: {str(e)}"
382-
)
381+
f"failed to generate EAPI '{self}'"
382+
) from e
383383

384384
for phase in self.phases.values():
385385
eapi_lib = pjoin(const.EBD_PATH, ".generated", "libs", self._magic, phase)
@@ -394,8 +394,8 @@ def bash_libs(self):
394394
)
395395
except (IOError, subprocess.CalledProcessError) as e:
396396
raise Exception(
397-
f"failed to generate EAPI '{self}' phase {phase} lib: {str(e)}"
398-
)
397+
f"failed to generate EAPI '{self}' phase {phase}"
398+
) from e
399399

400400
@klass.jit_attr
401401
def archive_exts_regex_pattern(self):

tests/ebuild/test_eapi.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import pytest
55
from pkgcore.const import EBD_PATH
6-
from pkgcore.ebuild import eapi
6+
from pkgcore.ebuild import eapi as eapi_mod
77
from pkgcore.ebuild.eapi import EAPI, get_eapi
88

99

@@ -43,36 +43,36 @@ def test_get_eapi():
4343
assert unknown_eapi == get_eapi("unknown")
4444

4545
# known EAPI
46-
assert get_eapi("6") == eapi.eapi6
46+
assert get_eapi("6") == eapi_mod.eapi6
4747

4848

4949
def test_get_PMS_eapi():
5050
# test PMS filtration
51-
assert get_eapi("6") is eapi.eapi6
51+
assert get_eapi("6") is eapi_mod.eapi6
5252
# hold the reference, known_eapis is weakval
5353
temp = EAPI.register("1234")
5454
# confirm it's visable
5555
assert get_eapi("1234", suppress_unsupported=False) is temp
56-
assert eapi.get_PMS_eapi("1234") is None
56+
assert eapi_mod.get_PMS_eapi("1234") is None
5757
temp2 = EAPI.register("9999", pms=True)
58-
assert eapi.get_PMS_eapi("9999") is temp2
58+
assert eapi_mod.get_PMS_eapi("9999") is temp2
5959

6060

6161
def test_get_PMS_eapis():
62-
pms_eapis = set(eapi.get_PMS_eapis())
62+
pms_eapis = set(eapi_mod.get_PMS_eapis())
6363
expected = set(x for x in EAPI.known_eapis.values() if x.pms)
6464
assert pms_eapis == expected
6565

6666

6767
def test_get_latest_pms_eapi():
6868
# if it's not in there, the magic constant isn't in alignment
69-
assert eapi.get_latest_PMS_eapi() in list(eapi.get_PMS_eapis())
69+
assert eapi_mod.get_latest_PMS_eapi() in list(eapi_mod.get_PMS_eapis())
7070

7171
# Note, this can false positive while a new EAPI is being developed. If this
7272
# is an actual issue, then introduce a flag on EAPI objects that indicates 'latest pms',
7373
# and update get_latest_PMS_eapi to scan for that, and register() to block duplicate.
7474
assert (
75-
eapi.get_latest_PMS_eapi()
75+
eapi_mod.get_latest_PMS_eapi()
7676
is sorted(
7777
(x for x in EAPI.known_eapis.values() if x.pms),
7878
key=lambda e: int(e._magic),
@@ -94,7 +94,7 @@ def test_register(self, tmp_path):
9494
mock_ebd_temp = str(shutil.copytree(EBD_PATH, tmp_path / "ebd"))
9595
with (
9696
mock.patch("pkgcore.ebuild.eapi.bash_version") as bash_version,
97-
mock.patch.dict(eapi.EAPI.known_eapis),
97+
mock.patch.dict(eapi_mod.EAPI.known_eapis),
9898
mock.patch("pkgcore.ebuild.eapi.const.EBD_PATH", mock_ebd_temp),
9999
):
100100
# inadequate bash version
@@ -115,11 +115,11 @@ def test_register(self, tmp_path):
115115
assert test_eapi._magic == "test1"
116116

117117
def test_is_supported(self, tmp_path, caplog):
118-
assert eapi.eapi6.is_supported
118+
assert eapi_mod.eapi6.is_supported
119119

120120
mock_ebd_temp = str(shutil.copytree(EBD_PATH, tmp_path / "ebd"))
121121
with (
122-
mock.patch.dict(eapi.EAPI.known_eapis),
122+
mock.patch.dict(eapi_mod.EAPI.known_eapis),
123123
mock.patch("pkgcore.ebuild.eapi.const.EBD_PATH", mock_ebd_temp),
124124
):
125125
# partially supported EAPI is flagged as such

0 commit comments

Comments
 (0)