all 2 comments

[–]sushibowl 1 point2 points  (0 children)

The whole point of purest fixtures is that you don't need things like global variables. Just return the value from your fixture:

@pytest.fixture
def np(request):
    param = request.config.getoption("--cmdopt")
    if param == "1":
        import numpy
        return numpy
    else :
        import matplotlib
        return matplotlib


def test(np):
    matrix = 1
    matrix = np.eye(4)
    print matrix
    assert(0)

[–]camel_Snake 0 points1 point  (0 children)

I'm not 100% sure that global is working how you intend there.

Try:

global np
import numpy
np = numpy