Skip to content

Commit 5d5f480

Browse files
committed
Hardening an existing test for demonstrating this change.
1 parent 329f56e commit 5d5f480

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

testing/test_collection.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,8 @@ def test_2():
685685
def test_example_items1(self, testdir):
686686
p = testdir.makepyfile(
687687
"""
688+
import pytest
689+
688690
def testone():
689691
pass
690692
@@ -693,19 +695,24 @@ def testmethod_one(self):
693695
pass
694696
695697
class TestY(TestX):
696-
pass
698+
@pytest.mark.parametrize("arg0", [".["])
699+
def testmethod_two(self, arg0):
700+
pass
697701
"""
698702
)
699703
items, reprec = testdir.inline_genitems(p)
700-
assert len(items) == 3
704+
assert len(items) == 4
701705
assert items[0].name == "testone"
702706
assert items[1].name == "testmethod_one"
703707
assert items[2].name == "testmethod_one"
708+
assert items[3].name == "testmethod_two[.[]"
704709

705710
# let's also test getmodpath here
706711
assert items[0].getmodpath() == "testone"
707712
assert items[1].getmodpath() == "TestX.testmethod_one"
708713
assert items[2].getmodpath() == "TestY.testmethod_one"
714+
# PR #6202: Fix incorrect result of getmodpath method. (Resolves issue #6189)
715+
assert items[3].getmodpath() == "TestY.testmethod_two[.[]"
709716

710717
s = items[0].getmodpath(stopatmodule=False)
711718
assert s.endswith("test_example_items1.testone")

0 commit comments

Comments
 (0)