Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/iris/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,12 @@ def get_dir_option(section, option, default=None):
# Override the data repository if the appropriate environment variable
# has been set. This is used in setup.py in the TestRunner command to
# enable us to simulate the absence of external data.
if os.environ.get("override_test_data_repository"):
TEST_DATA_DIR = None
override = os.environ.get("override_test_data_repository")
if override:
if override == '1':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the passed value is neither '1' nor a proper path to the test data?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then the test data directory will not be found, and the tests will fall back to the 'no data' approach of skipping

TEST_DATA_DIR = None
else:
TEST_DATA_DIR = override
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marqh We may want to be a wee bit more general here, see how the iris.tests.runner._runner.finalize_options sets this environment variable.

How about:

if os.path.isdir(override):
    TEST_DATA_DIR = override
else:
    TEST_DATA_DIR = None

Also, I think it's pretty bad style to have lower case environment variables ... now might be an opportunity to change that (if you care) since we're in this space ... 😉

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dkillick @marqh I think that we need to fix this given the comment above. The finalize_options sets the override_test_data_repository = 'true' which means the above merged code won't behave as intended ...


PALETTE_PATH = get_dir_option(_RESOURCE_SECTION, 'palette_path',
os.path.join(CONFIG_PATH, 'palette'))
Expand Down