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

Method test_example_items1

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

Source from the content-addressed store, hash-verified

695 assert i != j
696
697 def test_example_items1(self, pytester: Pytester) -> None:
698 p = pytester.makepyfile(
699 """
700 import pytest
701
702 def testone():
703 pass
704
705 class TestX(object):
706 def testmethod_one(self):
707 pass
708
709 class TestY(TestX):
710 @pytest.mark.parametrize("arg0", [".["])
711 def testmethod_two(self, arg0):
712 pass
713 """
714 )
715 items, reprec = pytester.inline_genitems(p)
716 assert len(items) == 4
717 assert items[0].name == "testone"
718 assert items[1].name == "testmethod_one"
719 assert items[2].name == "testmethod_one"
720 assert items[3].name == "testmethod_two[.[]"
721
722 # let's also test getmodpath here
723 assert items[0].getmodpath() == "testone" # type: ignore[attr-defined]
724 assert items[1].getmodpath() == "TestX.testmethod_one" # type: ignore[attr-defined]
725 assert items[2].getmodpath() == "TestY.testmethod_one" # type: ignore[attr-defined]
726 # PR #6202: Fix incorrect result of getmodpath method. (Resolves issue #6189)
727 assert items[3].getmodpath() == "TestY.testmethod_two[.[]" # type: ignore[attr-defined]
728
729 s = items[0].getmodpath(stopatmodule=False) # type: ignore[attr-defined]
730 assert s.endswith("test_example_items1.testone")
731 print(s)
732
733 def test_class_and_functions_discovery_using_glob(self, pytester: Pytester) -> None:
734 """Test that Python_classes and Python_functions config options work

Callers

nothing calls this directly

Calls 3

getmodpathMethod · 0.80
makepyfileMethod · 0.45
inline_genitemsMethod · 0.45

Tested by

no test coverage detected