From 492e0381946a69d9e99a2d90853edf3e5dd93bd5 Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Mon, 15 Aug 2016 15:00:47 -0600 Subject: [PATCH] Change implementation of default test_dir for TestStatus For some reason, some tests in scripts_regression_tests were failing for me with the old version of this code - maybe because default arguments are evaluated when the function is defined (not when it is called)? This new version seems more likely to be what's wanted - i.e., getting the current working directory at the time when the function is called, not the time when it's defined. From a quick look, it looks like this default could be removed entirely and made a required argument. Test suite: None Test baseline: N/A Test namelist changes: N/A Test status: N/A Fixes: None User interface changes?: No Code review: None --- utils/python/CIME/test_status.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/utils/python/CIME/test_status.py b/utils/python/CIME/test_status.py index 7398ccf7b235..c2bc9a040071 100644 --- a/utils/python/CIME/test_status.py +++ b/utils/python/CIME/test_status.py @@ -62,7 +62,14 @@ def _test_helper2(file_contents, wait_for_run=False, check_throughput=False, che class TestStatus(object): - def __init__(self, test_dir=os.getcwd(), test_name=None): + def __init__(self, test_dir=None, test_name=None): + """ + Create a TestStatus object + + If test_dir is not specified, it is set to the current working directory + """ + if test_dir is None: + test_dir = os.getcwd() self._filename = os.path.join(test_dir, TEST_STATUS_FILENAME) self._phase_statuses = OrderedDict() # {name -> (status, comments)} self._test_name = test_name