1

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)
Pierrick Rambaud
  • 1,726
  • 1
  • 20
  • 47
  • 2
    `session.run()` accepts `env` as a keyword argument to pass in environment variables e.g. `session.run("pytest", env={"EE_DECRYPT_KEY":"some_value"})`. See https://nox.thea.codes/en/stable/config.html – equatorial_daydreamer Nov 18 '22 at 16:00

0 Answers0