Show fixture scopes with ``--fixtures``, except for "function" scope (#5221)
Show fixture scopes with ``--fixtures``, except for "function" scope
This commit is contained in:
commit
2051e30b9b
|
@ -0,0 +1 @@
|
||||||
|
``--fixtures`` now also shows fixture scope for scopes other than ``"function"``.
|
|
@ -1342,17 +1342,19 @@ def _showfixtures_main(config, session):
|
||||||
currentmodule = module
|
currentmodule = module
|
||||||
if verbose <= 0 and argname[0] == "_":
|
if verbose <= 0 and argname[0] == "_":
|
||||||
continue
|
continue
|
||||||
|
tw.write(argname, green=True)
|
||||||
|
if fixturedef.scope != "function":
|
||||||
|
tw.write(" [%s scope]" % fixturedef.scope, cyan=True)
|
||||||
if verbose > 0:
|
if verbose > 0:
|
||||||
funcargspec = "%s -- %s" % (argname, bestrel)
|
tw.write(" -- %s" % bestrel, yellow=True)
|
||||||
else:
|
tw.write("\n")
|
||||||
funcargspec = argname
|
|
||||||
tw.line(funcargspec, green=True)
|
|
||||||
loc = getlocation(fixturedef.func, curdir)
|
loc = getlocation(fixturedef.func, curdir)
|
||||||
doc = fixturedef.func.__doc__ or ""
|
doc = fixturedef.func.__doc__ or ""
|
||||||
if doc:
|
if doc:
|
||||||
write_docstring(tw, doc)
|
write_docstring(tw, doc)
|
||||||
else:
|
else:
|
||||||
tw.line(" %s: no docstring available" % (loc,), red=True)
|
tw.line(" %s: no docstring available" % (loc,), red=True)
|
||||||
|
tw.line()
|
||||||
|
|
||||||
|
|
||||||
def write_docstring(tw, doc, indent=" "):
|
def write_docstring(tw, doc, indent=" "):
|
||||||
|
|
|
@ -3037,11 +3037,25 @@ class TestShowFixtures(object):
|
||||||
|
|
||||||
def test_show_fixtures(self, testdir):
|
def test_show_fixtures(self, testdir):
|
||||||
result = testdir.runpytest("--fixtures")
|
result = testdir.runpytest("--fixtures")
|
||||||
result.stdout.fnmatch_lines(["*tmpdir*", "*temporary directory*"])
|
result.stdout.fnmatch_lines(
|
||||||
|
[
|
||||||
|
"tmpdir_factory [[]session scope[]]",
|
||||||
|
"*for the test session*",
|
||||||
|
"tmpdir",
|
||||||
|
"*temporary directory*",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
def test_show_fixtures_verbose(self, testdir):
|
def test_show_fixtures_verbose(self, testdir):
|
||||||
result = testdir.runpytest("--fixtures", "-v")
|
result = testdir.runpytest("--fixtures", "-v")
|
||||||
result.stdout.fnmatch_lines(["*tmpdir*--*tmpdir.py*", "*temporary directory*"])
|
result.stdout.fnmatch_lines(
|
||||||
|
[
|
||||||
|
"tmpdir_factory [[]session scope[]] -- *tmpdir.py*",
|
||||||
|
"*for the test session*",
|
||||||
|
"tmpdir -- *tmpdir.py*",
|
||||||
|
"*temporary directory*",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
def test_show_fixtures_testmodule(self, testdir):
|
def test_show_fixtures_testmodule(self, testdir):
|
||||||
p = testdir.makepyfile(
|
p = testdir.makepyfile(
|
||||||
|
|
Loading…
Reference in New Issue