From b99c5d2abe3c601f5cc43d198b187c4c13d391b5 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sun, 17 Mar 2019 23:04:04 -0400 Subject: [PATCH] Use confdir if provided even when in CI --- tests/conftest.py | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 5f0dd51a..d8dfb84c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -35,16 +35,31 @@ def test_config(): return dirpath -@pytest.fixture(scope='session') -def travis(): +@pytest.fixture(scope='session', autouse=True) +def confdir(request, test_config): + """If the `--confdir` flag is not passed use the + broker config file found in that dir. + """ + confdir = request.config.option.confdir + if confdir is not None: + config._override_config_dir(confdir) + + # return config.load()[0] + return confdir + + +@pytest.fixture(scope='session', autouse=True) +def travis(confdir): is_travis = os.environ.get('TRAVIS', False) if is_travis: # this directory is cached, see .travis.yaml - cache_dir = config.get_broker_conf_path() + cache_dir = confdir or config.get_broker_conf_path() refresh_token = os.environ['QT_REFRESH_TOKEN'] def write_with_token(token): - conf, path = config.load(cache_dir) + # XXX don't pass the dir path here since may be + # written behind the scenes in the `confdir fixture` + conf, path = config.load() conf.setdefault('questrade', {}).update( {'refresh_token': token, 'is_practice': 'True'} @@ -76,18 +91,6 @@ def travis(): trio.run(ensure_config) -@pytest.fixture(scope='session', autouse=True) -def brokerconf(request, test_config, travis): - """If the `--confdir` flag is not passed use the - broker config file found in that dir. - """ - confdir = request.config.option.confdir - if confdir is not None: - config._override_config_dir(confdir) - - return config.load()[0] - - @pytest.fixture def us_symbols(): return ['TSLA', 'AAPL', 'CGC', 'CRON']