I have the following structure:
demo/
conftest.py
test_1.py
test_2.py
with conftest.py
content being:
import pytest
@pytest.fixture()
def my_fixture():
print "testing"*
and test_1.py
content being:
def test_my_fixture(my_fixture):
my_fixture
and test_2.py
content being:
import pytest
@pytest.mark.usefixtures('my_fixture')
def test_my_fixture():
my_fixture
When executed tests with py.test -s
, I get NameError
for the fixture in test_2.py
but not in test_1.py
; why?
Here is the output:
================ test session starts ================
platform linux2 -- Python 2.7.3 -- py-1.4.26 -- pytest-2.6.4
plugins: timeout, random
collected 2 items
test_1.py testing
.
test_2.py testing
F
===================== FAILURES ======================
__________________ test_my_fixture __________________
def test_my_fixture():
> my_fixture
E NameError: global name 'my_fixture' is not defined
test_2.py:7: NameError
Aucun commentaire:
Enregistrer un commentaire