MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_check_equality

Method test_check_equality

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

getmodulecolMethod · 0.45
collect_by_nameMethod · 0.45

Tested by

no test coverage detected