Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the rootdir parameter value while executing pytest

Tags:

python

pytest

After executing the pytest I could see its populating the rootdir in results based on the path of "pytest.ini". My issue is I need to use relative path to read some of the files as part of testing, so is there a way to fetch this "rootdir" parameter value during test execution

like image 462
Mohd Faheem Avatar asked Oct 28 '25 03:10

Mohd Faheem


1 Answers

Use the request fixture. Example:

def test_ini(request):
    rootdir = request.config.rootdir
    assert (rootdir / 'pytest.ini').isfile()
like image 54
hoefling Avatar answered Oct 30 '25 13:10

hoefling



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!