Skip to content

Commit d941326

Browse files
committed
Fix parsing of boolean config options, such as minimal_uploads.
`store_true` for argparse doesn't actually look at value, only at presence,so `--option=false` is the same as `--option` and `--option=true`. `store` only stores strings, so tests like `if minimal` would succeed for `--minimal-uploads=false`.
1 parent 079ec6a commit d941326

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

tests/conftest.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,10 @@ def _get_id(config):
270270
raise ValueError('Invalid value for --id argument: "%s"' % id)
271271

272272

273+
def _get_bool_option(config, name, default='false'):
274+
return config.getoption(name, default=default).lower() == 'true'
275+
276+
273277
def _run(*args) -> str:
274278
process = subprocess.run(args, check=False, text=True,
275279
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@@ -475,7 +479,7 @@ def _mk_test_fname(data):
475479

476480

477481
def _save_or_upload(config, data):
478-
minimal = config.getoption('minimal_uploads')
482+
minimal = _get_bool_option(config, 'minimal_uploads')
479483
save = config.getoption('save_results')
480484
upload = config.getoption('upload_results')
481485
if upload and minimal:
@@ -562,7 +566,8 @@ def _upload_report(config, data):
562566
env = config.option.environment
563567

564568
url = config.getoption('server_url')
565-
minimal = config.getoption('minimal_uploads')
569+
minimal = _get_bool_option(config, 'minimal_uploads')
570+
print('Minimal: %s' % minimal)
566571
if minimal:
567572
data = _sanitize(data)
568573
resp = requests.post('%s/result' % url, json={'id': env['config']['id'],

0 commit comments

Comments
 (0)