From 9ec9d293f7b63644522ebd4f81e4d4612bb1460a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Tue, 22 Aug 2023 20:39:50 -0700 Subject: [PATCH] MAINT: Simplifying handling of choices --- pytest_remotedata/plugin.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pytest_remotedata/plugin.py b/pytest_remotedata/plugin.py index f85f1a3..07c4d46 100644 --- a/pytest_remotedata/plugin.py +++ b/pytest_remotedata/plugin.py @@ -14,8 +14,9 @@ def pytest_addoption(parser): # is 'none', but if it is specified without arguments (--remote-data), it # defaults to '--remote-data=any'. parser.addoption( - help="run tests with online data") "--remote-data", nargs="?", const='any', default='none', + help="run tests with online data", + choices=['astropy', 'any', 'github', 'none']) parser.addini( 'remote_data_strict', @@ -34,11 +35,6 @@ def pytest_configure(config): strict_check = bool(config.getini('remote_data_strict')) remote_data = config.getoption('remote_data') - options = ['astropy', 'any', 'github', 'none'] - if remote_data not in options: - raise pytest.UsageError( - "'{}' is not a valid source for remote data, " - "use one of '{}'".format(remote_data, "', '".join(options))) # Monkeypatch to deny access to remote resources unless explicitly told # otherwise