Skip to content

Commit

Permalink
Change implementation of default test_dir for TestStatus
Browse files Browse the repository at this point in the history
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
  • Loading branch information
billsacks committed Aug 15, 2016
1 parent cdb9fb2 commit 492e038
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion utils/python/CIME/test_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 492e038

Please sign in to comment.