@@ -48,7 +48,23 @@ class A:
4848 def f (self , arg1 , arg2 = "hello" ):
4949 raise NotImplementedError ()
5050
51+ def g (self , / , arg1 , arg2 = "hello" ):
52+ raise NotImplementedError ()
53+
54+ def h (self , * , arg1 , arg2 = "hello" ):
55+ raise NotImplementedError ()
56+
57+ def j (self , arg1 , * , arg2 , arg3 = "hello" ):
58+ raise NotImplementedError ()
59+
60+ def k (self , / , arg1 , * , arg2 , arg3 = "hello" ):
61+ raise NotImplementedError ()
62+
5163 assert getfuncargnames (A ().f ) == ("arg1" ,)
64+ assert getfuncargnames (A ().g ) == ("arg1" ,)
65+ assert getfuncargnames (A ().h ) == ("arg1" ,)
66+ assert getfuncargnames (A ().j ) == ("arg1" , "arg2" )
67+ assert getfuncargnames (A ().k ) == ("arg1" , "arg2" )
5268
5369
5470def test_getfuncargnames_staticmethod ():
@@ -5033,3 +5049,22 @@ def test_foo(another_fixture):
50335049 )
50345050 result = pytester .runpytest ()
50355051 result .assert_outcomes (passed = 1 )
5052+
5053+
5054+ def test_collect_positional_only (pytester : Pytester ) -> None :
5055+ """Support the collection of tests with positional-only arguments (#13376)."""
5056+ pytester .makepyfile (
5057+ """
5058+ import pytest
5059+
5060+ class Test:
5061+ @pytest.fixture
5062+ def fix(self):
5063+ return 1
5064+
5065+ def test_method(self, /, fix):
5066+ assert fix == 1
5067+ """
5068+ )
5069+ result = pytester .runpytest ()
5070+ result .assert_outcomes (passed = 1 )
0 commit comments