I'm working on a program which has a config. I need to use a different config for the tests and the normal running of the program.
I manage all the software and tests using a manage.py
script and all the tests are under python manage.py test ...
(eg: python manage.py test all
, python manage.py test db
, ...)
To choose the config I did in the __init__.py
of the config:
is_testing = sys.argv[1] == 'test'
if is_testing:
from app.config.own import TestConfig as Config
else:
from app.config.own import Config
and after I import the config from this file.
But sometime the test runner takes the first place in the argv so the test is in argv[2] or sometimes I run the tests by launching the script directly and not the manage.py
.
My question is by which ways can I share a variable across the full codebase?
Thanks.