MCPcopy
hub / github.com/pytest-dev/pytest / test_check_equality

Method test_check_equality

testing/test_collection.py:42–71  ·  view source on GitHub ↗
(self, pytester: Pytester)

Source from the content-addressed store, hash-verified

40 assert not issubclass(Item, Collector)
41
42 def test_check_equality(self, pytester: Pytester) -> None:
43 modcol = pytester.getmodulecol(
44 """
45 def test_pass(): pass
46 def test_fail(): assert 0
47 """
48 )
49 fn1 = pytester.collect_by_name(modcol, "test_pass")
50 assert isinstance(fn1, pytest.Function)
51 fn2 = pytester.collect_by_name(modcol, "test_pass")
52 assert isinstance(fn2, pytest.Function)
53
54 assert fn1 == fn2
55 assert fn1 != modcol
56 assert hash(fn1) == hash(fn2)
57
58 fn3 = pytester.collect_by_name(modcol, "test_fail")
59 assert isinstance(fn3, pytest.Function)
60 assert not (fn1 == fn3)
61 assert fn1 != fn3
62
63 for fn in fn1, fn2, fn3:
64 assert isinstance(fn, pytest.Function)
65 assert fn != 3 # type: ignore[comparison-overlap]
66 assert fn != modcol
67 assert fn != [1, 2, 3] # type: ignore[comparison-overlap]
68 assert [1, 2, 3] != fn # type: ignore[comparison-overlap]
69 assert modcol != fn
70
71 assert pytester.collect_by_name(modcol, "doesnotexist") is None
72
73 def test_getparent_and_accessors(self, pytester: Pytester) -> None:
74 modcol = pytester.getmodulecol(

Callers

nothing calls this directly

Calls 2

getmodulecolMethod · 0.45
collect_by_nameMethod · 0.45

Tested by

no test coverage detected