External
External

Reputation: 23

How to run a terminal command before running the tests in pytest?

I have written several tests in pytest. For one of them I need to run the following command in terminal :

PATH="$(pwd)/testing/scripting:$PATH" 

Since I want to run the tests in different machines I wanted to automate this process.

Upvotes: 0

Views: 1047

Answers (1)

Corralien
Corralien

Reputation: 120401

Maybe you can use conftest.py

Something like below:

import os

def pytest_sessionstart(session):
    path = os.path.join(os.getcwd(), 'testing/scripting')
    os.environ['PATH'] =  path + os.pathsep + os.environ['PATH']

Upvotes: 1

Related Questions