Merge pull request #1575 from hackebrot/fix-showfixtures-for-multiple-fixturedefs
Fix showfixtures for multiple fixturedefs
This commit is contained in:
commit
fb2e7cc727
|
@ -24,6 +24,10 @@
|
||||||
* Minor improvements and fixes to the documentation.
|
* Minor improvements and fixes to the documentation.
|
||||||
Thanks `@omarkohl`_ for the PR.
|
Thanks `@omarkohl`_ for the PR.
|
||||||
|
|
||||||
|
* Fix ``--fixtures`` to show all fixture definitions as opposed to just
|
||||||
|
one per fixture name.
|
||||||
|
Thanks to `@hackebrot`_ for the PR.
|
||||||
|
|
||||||
.. _#510: https://github.com/pytest-dev/pytest/issues/510
|
.. _#510: https://github.com/pytest-dev/pytest/issues/510
|
||||||
.. _#1506: https://github.com/pytest-dev/pytest/pull/1506
|
.. _#1506: https://github.com/pytest-dev/pytest/pull/1506
|
||||||
.. _#1496: https://github.com/pytest-dev/pytest/issue/1496
|
.. _#1496: https://github.com/pytest-dev/pytest/issue/1496
|
||||||
|
|
|
@ -1168,7 +1168,7 @@ def _showfixtures_main(config, session):
|
||||||
assert fixturedefs is not None
|
assert fixturedefs is not None
|
||||||
if not fixturedefs:
|
if not fixturedefs:
|
||||||
continue
|
continue
|
||||||
fixturedef = fixturedefs[-1]
|
for fixturedef in fixturedefs:
|
||||||
loc = getlocation(fixturedef.func, curdir)
|
loc = getlocation(fixturedef.func, curdir)
|
||||||
available.append((len(fixturedef.baseid),
|
available.append((len(fixturedef.baseid),
|
||||||
fixturedef.func.__module__,
|
fixturedef.func.__module__,
|
||||||
|
|
|
@ -2564,6 +2564,38 @@ class TestShowFixtures:
|
||||||
Fixture B
|
Fixture B
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
def test_show_fixtures_with_same_name(self, testdir):
|
||||||
|
testdir.makeconftest('''
|
||||||
|
import pytest
|
||||||
|
@pytest.fixture
|
||||||
|
def arg1():
|
||||||
|
"""Hello World in conftest.py"""
|
||||||
|
return "Hello World"
|
||||||
|
''')
|
||||||
|
testdir.makepyfile('''
|
||||||
|
def test_foo(arg1):
|
||||||
|
assert arg1 == "Hello World"
|
||||||
|
''')
|
||||||
|
testdir.makepyfile('''
|
||||||
|
import pytest
|
||||||
|
@pytest.fixture
|
||||||
|
def arg1():
|
||||||
|
"""Hi from test module"""
|
||||||
|
return "Hi"
|
||||||
|
def test_bar(arg1):
|
||||||
|
assert arg1 == "Hi"
|
||||||
|
''')
|
||||||
|
result = testdir.runpytest("--fixtures")
|
||||||
|
result.stdout.fnmatch_lines('''
|
||||||
|
* fixtures defined from conftest *
|
||||||
|
arg1
|
||||||
|
Hello World in conftest.py
|
||||||
|
|
||||||
|
* fixtures defined from test_show_fixtures_with_same_name *
|
||||||
|
arg1
|
||||||
|
Hi from test module
|
||||||
|
''')
|
||||||
|
|
||||||
|
|
||||||
class TestContextManagerFixtureFuncs:
|
class TestContextManagerFixtureFuncs:
|
||||||
def test_simple(self, testdir):
|
def test_simple(self, testdir):
|
||||||
|
|
Loading…
Reference in New Issue