MCPcopy Index your code
hub / github.com/pytest-dev/pytest / test_example_items1

Method test_example_items1

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

Source from the content-addressed store, hash-verified

743 assert i != j
744
745 def test_example_items1(self, pytester: Pytester) -> None:
746 p = pytester.makepyfile(
747 """
748 import pytest
749
750 def testone():
751 pass
752
753 class TestX(object):
754 def testmethod_one(self):
755 pass
756
757 class TestY(TestX):
758 @pytest.mark.parametrize("arg0", [".["])
759 def testmethod_two(self, arg0):
760 pass
761 """
762 )
763 items, _reprec = pytester.inline_genitems(p)
764 assert len(items) == 4
765 assert items[0].name == "testone"
766 assert items[1].name == "testmethod_one"
767 assert items[2].name == "testmethod_one"
768 assert items[3].name == "testmethod_two[.[]"
769
770 # let's also test getmodpath here
771 assert items[0].getmodpath() == "testone" # type: ignore[attr-defined]
772 assert items[1].getmodpath() == "TestX.testmethod_one" # type: ignore[attr-defined]
773 assert items[2].getmodpath() == "TestY.testmethod_one" # type: ignore[attr-defined]
774 # PR #6202: Fix incorrect result of getmodpath method. (Resolves issue #6189)
775 assert items[3].getmodpath() == "TestY.testmethod_two[.[]" # type: ignore[attr-defined]
776
777 s = items[0].getmodpath(stopatmodule=False) # type: ignore[attr-defined]
778 assert s.endswith("test_example_items1.testone")
779 print(s)
780
781 def test_classmethod_is_discovered(self, pytester: Pytester) -> None:
782 """Test that classmethods are discovered"""

Callers

nothing calls this directly

Calls 4

getmodpathMethod · 0.80
endswithMethod · 0.80
makepyfileMethod · 0.45
inline_genitemsMethod · 0.45

Tested by

no test coverage detected