0

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.

External
  • 23
  • 3
  • What about using a bash script to set the environment and then run Python? – jfaccioni Mar 02 '22 at 17:26
  • As your terminal command is just a modification of an environment variable, one of the answers here might be helpful: https://stackoverflow.com/questions/36141024/how-to-pass-environment-variables-to-pytest – mad Mar 04 '22 at 12:08

1 Answers1

1

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']
Corralien
  • 109,409
  • 8
  • 28
  • 52