mardi 22 janvier 2019

how to use pytest fixture in all module once declared without importing it

i am testing in python.

in my confest.py file i have function session which i am using as a fixture

# confest.py
@pytest.fixture
def session():
    # code here

now i want to use this fixture in the other module for testing.

when i am importing this fixture as from confest import session my code is working fine as required.

but since it is a fixture i shouldn't need to call this in my module ( as per myknowledge) pytest will automatically take care of it.

content of other module xyz.py

from confest import session
@pytest.mark.abc
def test_function(session):
     # code here

the above is working fine.

i want to not import session from confest.py.so pytest automatically care of it.

what changes i need to make for this.

thanks and regards

Aucun commentaire:

Enregistrer un commentaire