how to use environment variable in a nox session?

833 Views Asked by At

I want to use nox to run my test suit in a controlled environment. To perfectly work I need to pass an environment variable from my normal env to the virtual one is it possible and if yes how ?

@nox.session(name="test", python="3.8")
def test(session):
    
    # intall the venv
    if _should_install(session):
        session.install(".[test]")
        
        # install specific version of earthengine API for the SEPAL env
        if "sepal" in session.posargs:
            session.posargs.remove("sepal")
            session.install("git+https://github.com/custom_lib")

           # add a EE_DECRYPT_KEY env variable e.g. from the posargs
           # but how ?
    
    # run the tests
    session.run("pytest", *session.posargs)
0

There are 0 best solutions below