File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -1014,16 +1014,26 @@ def _showfixtures_main(config, session):
1014
1014
fm = session ._fixturemanager
1015
1015
1016
1016
available = []
1017
+ seen = set ()
1018
+
1017
1019
for argname , fixturedefs in fm ._arg2fixturedefs .items ():
1018
1020
assert fixturedefs is not None
1019
1021
if not fixturedefs :
1020
1022
continue
1021
1023
for fixturedef in fixturedefs :
1022
1024
loc = getlocation (fixturedef .func , curdir )
1025
+ fixture_argname = fixturedef .argname
1026
+ # invocation-scoped fixtures have argname in the form
1027
+ # "<name>:<scope>" (for example: "monkeypatch:session").
1028
+ if ':' in fixture_argname :
1029
+ fixture_argname = fixture_argname .split (':' )[0 ]
1030
+ if (fixture_argname , loc ) in seen :
1031
+ continue
1032
+ seen .add ((fixture_argname , loc ))
1023
1033
available .append ((len (fixturedef .baseid ),
1024
1034
fixturedef .func .__module__ ,
1025
1035
curdir .bestrelpath (loc ),
1026
- fixturedef . argname , fixturedef ))
1036
+ fixture_argname , fixturedef ))
1027
1037
1028
1038
available .sort ()
1029
1039
currentmodule = None
Original file line number Diff line number Diff line change @@ -2725,6 +2725,13 @@ def test_bar(arg1):
2725
2725
Hi from test module
2726
2726
''' )
2727
2727
2728
+ def test_show_invocation_fixtures (self , testdir ):
2729
+ """py.test --fixtures should display invocation-scoped fixtures once.
2730
+ """
2731
+ result = testdir .runpytest ("--fixtures" )
2732
+ result .stdout .fnmatch_lines ('''monkeypatch''' )
2733
+ assert 'monkeypatch:session' not in result .stdout .str ()
2734
+
2728
2735
2729
2736
@pytest .mark .parametrize ('flavor' , ['fixture' , 'yield_fixture' ])
2730
2737
class TestContextManagerFixtureFuncs :
You can’t perform that action at this time.
0 commit comments