Skip to content

Commit 5fd987d

Browse files
authored
Merge pull request #53 from Akuli/eq
prevent error from LazyFixture('lol') == 1
2 parents 986df35 + f1fb6c8 commit 5fd987d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pytest_lazyfixture.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,6 @@ def __repr__(self):
194194
return '<{} "{}">'.format(self.__class__.__name__, self.name)
195195

196196
def __eq__(self, other):
197-
return self.name == other.name
197+
if isinstance(other, LazyFixture):
198+
return self.name == other.name
199+
return NotImplemented

tests/test_lazyfixture.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,3 +904,9 @@ def test_the_thing(data):
904904
assert 'test_the_thing[foo]' in stdout
905905
assert 'test_the_thing[bar-spam]' in stdout
906906
assert 'test_the_thing[bar-eggs]' in stdout
907+
908+
909+
def test_eq():
910+
assert lazy_fixture("Lol") == lazy_fixture("Lol")
911+
assert lazy_fixture("Lol") != lazy_fixture("Wut")
912+
assert lazy_fixture("Lol") != 123

0 commit comments

Comments
 (0)