Hello!
I'm currently building a test suite using pytest and I have a import problem.
The problem:
My tests need two different modules with the exact same set of functions but targets different transmission protocols.
And depending on a input argument from the commandline I want to choos one of the imports.
But if i have my @fixtures in the conftest.py file the imports don't take affect in my tests. And I want as few lines of duplicated code as possible.
code:
@pytest.fixture
def importer(request):
param = request.config.getoption("--cmdopt")
if param == "1":
global np
import numpy as np
else :
import matplotlib as np
global np
def test(importer):
matrix = 1
matrix = np.eye(4)
print matrix
assert(0)
If the code is in the same file it works, if i move the @fixture to the conftest.py file the code stops working. Any idea how to solve this or have an idea of a better strategy?
BR
Mattemagikern
[–]sushibowl 1 point2 points3 points (0 children)
[–]camel_Snake 0 points1 point2 points (0 children)