Use confdir if provided even when in CI

kivy_mainline_and_py3.8
Tyler Goodlet 2019-03-17 23:04:04 -04:00
parent 3a439fc99d
commit b99c5d2abe
1 changed files with 19 additions and 16 deletions

View File

@ -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']