Skip to content

Commit 86488fe

Browse files
committed
fix tests for pkgcraft dropping support for EAPIs 0 to 4
1 parent c0cb098 commit 86488fe

4 files changed

Lines changed: 43 additions & 48 deletions

File tree

src/pkgcraft/eapi.pyx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,19 @@ cdef object get_eapis():
5252
def eapi_range(str s not None):
5353
"""Convert EAPI range into an ordered set of Eapi objects.
5454
55-
>>> from pkgcraft.eapi import eapi_range, EAPI3, EAPI4, EAPIS, EAPIS_OFFICIAL
55+
>>> from pkgcraft.eapi import *
5656
5757
>>> eapi_range('..') == set(EAPIS.values())
5858
True
59-
>>> eapi_range('..2') == {EAPI0, EAPI1}
59+
>>> eapi_range('..6') == {EAPI5}
6060
True
61-
>>> eapi_range('3..4') == {EAPI3}
61+
>>> eapi_range('..=6') == {EAPI5, EAPI6}
6262
True
63-
>>> eapi_range('3..=4') == {EAPI3, EAPI4}
63+
>>> eapi_range('7..8') == {EAPI7}
64+
True
65+
>>> eapi_range('8..8') == set()
66+
True
67+
>>> eapi_range('7..=8') == {EAPI7, EAPI8}
6468
True
6569
>>> eapi_range('..9999')
6670
Traceback (most recent call last):
@@ -121,18 +125,18 @@ cdef class Eapi(_IndirectInit):
121125
def has(self, str s not None):
122126
"""Check if an EAPI has a given feature.
123127
124-
>>> from pkgcraft.eapi import EAPI5
128+
>>> from pkgcraft.eapi import EAPI_LATEST_OFFICIAL
125129
126130
existing feature
127-
>>> EAPI5.has('subslots')
131+
>>> EAPI_LATEST_OFFICIAL.has('usev_two_args')
128132
True
129133
130-
newer feature not existing in EAPI 5
131-
>>> EAPI5.has('nonfatal_die')
134+
feature not existing in official EAPIs
135+
>>> EAPI_LATEST_OFFICIAL.has('repo_ids')
132136
False
133137
134138
nonexistent feature
135-
>>> EAPI5.has('nonexistent')
139+
>>> EAPI_LATEST_OFFICIAL.has('nonexistent')
136140
False
137141
"""
138142
return C.pkgcraft_eapi_has(self.ptr, s.encode())

tests/repo/test_ebuild.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import pytest
66

7-
from pkgcraft.eapi import EAPI0, EAPI_LATEST_OFFICIAL
7+
from pkgcraft.eapi import EAPI_LATEST_OFFICIAL
88
from pkgcraft.error import InvalidRepo
99
from pkgcraft.repo import EbuildRepo, Repo
1010

@@ -77,14 +77,14 @@ def test_contains_path(self, make_ebuild_repo):
7777
assert pkg2.path in r2
7878

7979
def test_eapi(self, make_raw_ebuild_repo):
80-
# non-present defaults to EAPI 0
80+
# non-present defaults to EAPI 0 which isn't supported
8181
repo = make_raw_ebuild_repo(eapi=None)
82-
r = EbuildRepo(repo.path)
83-
assert r.eapi is EAPI0
82+
with pytest.raises(InvalidRepo, match="unsupported EAPI: 0"):
83+
EbuildRepo(repo.path)
8484

8585
# invalid EAPI
8686
repo = make_raw_ebuild_repo(eapi="abc123")
87-
with pytest.raises(InvalidRepo, match="unknown EAPI: abc123"):
87+
with pytest.raises(InvalidRepo, match="unsupported EAPI: abc123"):
8888
EbuildRepo(repo.path)
8989

9090
# defaults to latest EAPI

tests/test_eapi.py

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,7 @@
22

33
import pytest
44

5-
from pkgcraft.eapi import (
6-
EAPI0,
7-
EAPI1,
8-
EAPI_LATEST,
9-
EAPI_LATEST_OFFICIAL,
10-
EAPIS,
11-
EAPIS_OFFICIAL,
12-
Eapi,
13-
)
5+
from pkgcraft.eapi import *
146

157
from .misc import OperatorMap
168

@@ -27,40 +19,39 @@ def test_globals():
2719

2820
class TestEapi:
2921
def test_has(self):
30-
assert not EAPI1.has("nonexistent_feature")
31-
assert EAPI1.has("slot_deps")
22+
assert not EAPI_LATEST_OFFICIAL.has("repo_ids")
23+
assert EAPI_LATEST.has("repo_ids")
24+
assert not EAPI_LATEST.has("nonexistent_feature")
3225

3326
# invalid feature param type
3427
for obj in (object(), None):
3528
with pytest.raises(TypeError):
36-
EAPI1.has(obj)
29+
EAPI_LATEST.has(obj)
3730

3831
def test_dep_keys(self):
39-
assert "DEPEND" in EAPI0.dep_keys
40-
assert "BDEPEND" not in EAPI0.dep_keys
4132
assert "BDEPEND" in EAPI_LATEST.dep_keys
33+
assert "NONEXISTENT" not in EAPI_LATEST.dep_keys
4234

4335
def test_metadata_keys(self):
44-
assert "SLOT" in EAPI0.metadata_keys
45-
assert "REQUIRED_USE" not in EAPI0.metadata_keys
46-
assert "REQUIRED_USE" in EAPI_LATEST.metadata_keys
36+
assert "SLOT" in EAPI_LATEST.metadata_keys
37+
assert "NONEXISTENT" not in EAPI_LATEST.metadata_keys
4738

4839
def test_methods(self):
49-
assert str(EAPI0) == "0"
50-
assert repr(EAPI0).startswith("<Eapi '0' at 0x")
40+
assert str(EAPI8) == "8"
41+
assert repr(EAPI8).startswith("<Eapi '8' at 0x")
5142

5243
def test_cmp(self):
53-
assert EAPI0 < EAPI1
54-
assert EAPI0 <= EAPI1
55-
assert EAPI1 <= EAPI1
56-
assert EAPI1 == EAPI1
57-
assert EAPI0 != EAPI1
58-
assert EAPI1 >= EAPI1
59-
assert EAPI1 >= EAPI0
60-
assert EAPI1 > EAPI0
44+
assert EAPI7 < EAPI8
45+
assert EAPI8 <= EAPI8
46+
assert EAPI8 <= EAPI8
47+
assert EAPI8 == EAPI8
48+
assert EAPI7 != EAPI8
49+
assert EAPI8 >= EAPI7
50+
assert EAPI8 >= EAPI7
51+
assert EAPI8 > EAPI7
6152

6253
# verify incompatible type comparisons
63-
obj = EAPI0
54+
obj = EAPI_LATEST
6455
for op, op_func in OperatorMap.items():
6556
if op == "==":
6657
assert not op_func(obj, None)
@@ -71,14 +62,14 @@ def test_cmp(self):
7162
op_func(obj, None)
7263

7364
def test_hash(self):
74-
s = {EAPI0, EAPI1}
65+
s = {EAPI7, EAPI8}
7566
assert len(s) == 2
76-
s = {EAPI0, EAPI0}
67+
s = {EAPI8, EAPI8}
7768
assert len(s) == 1
7869

7970
def test_from_obj(self):
80-
assert Eapi.from_obj(EAPI0) is EAPI0
81-
assert Eapi.from_obj("0") is EAPI0
71+
assert Eapi.from_obj(EAPI8) is EAPI8
72+
assert Eapi.from_obj("8") is EAPI8
8273

8374
# unknown EAPI
8475
with pytest.raises(ValueError):
@@ -89,6 +80,6 @@ def test_from_obj(self):
8980
assert Eapi.from_obj(object())
9081

9182
def test_eapi_pickle(self):
92-
e1 = EAPI0
83+
e1 = EAPI8
9384
e2 = pickle.loads(pickle.dumps(e1))
9485
assert e1 is e2

0 commit comments

Comments
 (0)