Skip to content

Commit

Permalink
Merge pull request #435 from billsacks/fix_pylint_problems
Browse files Browse the repository at this point in the history
Fix problems discovered by pylint / code_checker
  • Loading branch information
jedwards4b authored Aug 20, 2016
2 parents 94b27aa + 3d62b25 commit 50f145b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 23 deletions.
1 change: 0 additions & 1 deletion utils/python/CIME/SystemTests/test_utils/user_nl_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
This module contains functions for working with user_nl files in system tests.
"""

import shutil
import os
import glob

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
This module contains unit tests of the core logic in SystemTestsCompareTwo.
"""

# Ignore privacy concerns for unit tests, so that unit tests can access
# protected members of the system under test
#
# pylint:disable=protected-access

import unittest
from collections import namedtuple
import os
Expand All @@ -18,19 +23,17 @@
# Structure for storing information about calls made to methods
# ========================================================================

"""
You can create a Call object to record a single call made to a method:
Call(method, arguments)
method (str): name of method
arguments (dict): dictionary mapping argument names to values
Example:
If you want to record a call to foo(bar = 1, baz = 2):
somecall = Call(method = 'foo', arguments = {'bar': 1, 'baz': 2})
Or simply:
somecall = Call('foo', {'bar': 1, 'baz': 2})
"""
# You can create a Call object to record a single call made to a method:
#
# Call(method, arguments)
# method (str): name of method
# arguments (dict): dictionary mapping argument names to values
#
# Example:
# If you want to record a call to foo(bar = 1, baz = 2):
# somecall = Call(method = 'foo', arguments = {'bar': 1, 'baz': 2})
# Or simply:
# somecall = Call('foo', {'bar': 1, 'baz': 2})
Call = namedtuple('Call', ['method', 'arguments'])

# ========================================================================
Expand Down Expand Up @@ -135,7 +138,7 @@ def _init_case_setup(self):
# SystemTestsCommon
# ------------------------------------------------------------------------

def run_indv(self, suffix="base"):
def run_indv(self, suffix="base", coupler_log_path=None, st_archive=False):
"""
This fake implementation appends to the log and raises an exception if
it's supposed to
Expand Down Expand Up @@ -295,9 +298,9 @@ def test_setup_error(self):

# Exercise
with self.assertRaises(Exception):
mytest = SystemTestsCompareTwoFake(case1,
run_two_suffix = 'test',
case2setup_raises_exception = True)
SystemTestsCompareTwoFake(case1,
run_two_suffix = 'test',
case2setup_raises_exception = True)

# Verify
self.assertFalse(os.path.exists(os.path.join(case1root, 'case1.test')))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
SystemTestsCompareTwo._link_to_case2_output
"""

# Ignore privacy concerns for unit tests, so that unit tests can access
# protected members of the system under test
#
# pylint:disable=protected-access

import unittest
import os
import shutil
Expand Down Expand Up @@ -132,7 +137,7 @@ def test_existing_link(self):
run2_suffix = 'run2'

mytest = self.setup_test_and_directories(casename1, run2_suffix)
filepath1 = self.create_file_in_rundir2(mytest, 'clm2.h0', run2_suffix)
self.create_file_in_rundir2(mytest, 'clm2.h0', run2_suffix)

# Create initial link via a call to _link_to_case2_output
mytest._link_to_case2_output()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def test_append_without_files_raises_exception(self):

# Setup
# Create file in caseroot for component_exists, but not for component_for_append
filename = self.write_user_nl_file(component_exists, 'irrelevant contents')
self.write_user_nl_file(component_exists, 'irrelevant contents')

# Exercise & verify
self.assertRaisesRegexp(RuntimeError, "No user_nl files found",
Expand Down
10 changes: 7 additions & 3 deletions utils/python/CIME/tests/case_fake.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, case_root, create_case_root=True):
casename = os.path.basename(case_root)
self.set_value('CASE', casename)
self.set_value('CASEBASEID', casename)
self._set_rundir()
self.set_rundir()

def get_value(self, item):
"""
Expand Down Expand Up @@ -58,11 +58,15 @@ def copy(self, newcasename, newcaseroot):
newcase.set_value('CASE', newcasename)
newcase.set_value('CASEBASEID', newcasename)
newcase.set_value('CASEROOT', newcaseroot)
newcase._set_rundir()
newcase.set_rundir()

return newcase

def create_clone(self, newcase, keepexe=False):
# Need to disable unused-argument checking: keepexe is needed to match
# the interface of Case, but is not used in this fake implementation
#
# pylint: disable=unused-argument
"""
Create a clone of the current case. Also creates the CASEROOT directory
for the clone case (given by newcase).
Expand Down Expand Up @@ -90,7 +94,7 @@ def make_rundir(self):
"""
os.makedirs(self.get_value('RUNDIR'))

def _set_rundir(self):
def set_rundir(self):
"""
Assumes CASEROOT is already set; sets an appropriate RUNDIR (nested
inside CASEROOT)
Expand Down

0 comments on commit 50f145b

Please sign in to comment.