From fb8ad714b10fd55b02996465899110df254f8406 Mon Sep 17 00:00:00 2001 From: Raphael Pierzina Date: Tue, 31 May 2016 11:46:35 +0100 Subject: [PATCH] Implement a test for showfixtures to show fixtures with same name --- testing/python/fixture.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/testing/python/fixture.py b/testing/python/fixture.py index 506d8426e..25e312098 100644 --- a/testing/python/fixture.py +++ b/testing/python/fixture.py @@ -2564,6 +2564,38 @@ class TestShowFixtures: 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: def test_simple(self, testdir):