I have a structure like this: ```root |--projectA/...
# general
b
I have a structure like this:
Copy code
root
|--projectA/
|--projectB/
|--pants.toml
In
pants.toml
, I have:
Copy code
[test]
extra_env_vars=["ENV_A", "ENVB"]
So, when I run
pants test
these env vars are injected. I want
projectA
to have a different set of env vars to
projectB
. Is there a way of nesting the
extra_env_vars
section inside of
projectA
and
projectB
so that they apply to all tests in the respective projects? Note: I'm looking for a way so that the env vars for a project are applied to all the tests for that project in one go.
b
I don't think so, not in Pants parlance. You could try to use
conftest.py
files though
b
any pointers on how that might work? If a monorepo has say, 5 projects, then would we need a uber extra_env_vars covering all environment variables needed by any of the projects listed in pants.toml? we wouldn't have the host's env vars available to conftest when pants is running tests in a sandbox, right?
b
Yeah, I wasn't thinking of the passthrough when I made that comment 🤔
I think your correct though, you could attempt to scrub the ones that didn't need to exist.
So each "root" sets a default to the right env vars
b
do you mean setting
python_tests.__defaults__.extra_env_vars
in the root
Buid
file, and hopefully that sets it on all the pything_tests? but then if two projects are built, is there a chance the values clash?
b
In the root of each project, yeah?
b
hmm... will give it a shot. Would be a nice feature to formally have though. Can I raise a feature request on github?