Skip to content

Commit 29696cb

Browse files
committed
tests: add invalid type tests for Restrict.dep() and Restrict.pkg()
1 parent debfe0d commit 29696cb

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

tests/test_restrict.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ def test_dep(self, fake_repo):
4646
pkg = fake_repo.create_pkg("cat/pkg-1")
4747
assert r.matches(pkg)
4848

49+
# invalid types
50+
for obj in (object(), None):
51+
with pytest.raises(TypeError):
52+
assert Restrict.dep(obj)
53+
4954
def test_pkg(self, ebuild_repo):
5055
with pytest.raises(InvalidRestrict):
5156
Restrict.pkg('description ~= "fake"')
@@ -54,6 +59,11 @@ def test_pkg(self, ebuild_repo):
5459
pkg = ebuild_repo.create_pkg("cat/pkg-1", description="fake pkg")
5560
assert r.matches(pkg)
5661

62+
# invalid types
63+
for obj in (object(), None):
64+
with pytest.raises(TypeError):
65+
assert Restrict.pkg(obj)
66+
5767
def test_matches(self, fake_repo):
5868
r = Restrict("cat/pkg")
5969
pkg1 = fake_repo.create_pkg("cat/pkg-1")
@@ -69,7 +79,7 @@ def test_matches(self, fake_repo):
6979
assert r.matches(pkg1)
7080
assert not r.matches(pkg2)
7181

72-
# unsupported types
82+
# invalid types
7383
for obj in (object(), None):
7484
with pytest.raises(TypeError):
7585
assert r.matches(obj)
@@ -113,7 +123,7 @@ def test_logic_ops(self, fake_repo):
113123
assert not list(fake_repo.iter(~(r1 | r2)))
114124
assert not list(fake_repo.iter(~(r1 ^ r2)))
115125

116-
# verify incompatible types for boolean combinations
126+
# verify invalid types for boolean combinations
117127
with pytest.raises(TypeError):
118128
r1 & None
119129
with pytest.raises(TypeError):

0 commit comments

Comments
 (0)