CIME.tests package

Submodules

CIME.tests.case_fake module

This module contains a fake implementation of the Case class that can be used for testing the tests.

class CIME.tests.case_fake.CaseFake(case_root, create_case_root=True)[source]

Bases: object

case_setup(clean=False, test_mode=False, reset=False)[source]
copy(newcasename, newcaseroot)[source]

Create and return a copy of self, but with CASE and CASEBASEID set to newcasename, CASEROOT set to newcaseroot, and RUNDIR set appropriately.

Args:

newcasename (str): new value for CASE newcaseroot (str): new value for CASEROOT

create_clone(newcase, keepexe=False, mach_dir=None, project=None, cime_output_root=None, exeroot=None, rundir=None)[source]

Create a clone of the current case. Also creates the CASEROOT directory for the clone case (given by newcase).

Args:
newcase (str): full path to the new case. This directory should not

already exist; it will be created

keepexe (bool, optional): Ignored mach_dir (str, optional): Ignored project (str, optional): Ignored cime_output_root (str, optional): New CIME_OUTPUT_ROOT for the clone exeroot (str, optional): New EXEROOT for the clone rundir (str, optional): New RUNDIR for the clone

Returns the clone case object

flush()[source]
get_value(item)[source]

Get the value of the given item

Returns None if item isn’t set for this case

Args:

item (str): variable of interest

load_env(reset=False)[source]
make_rundir()[source]

Make directory given by RUNDIR

set_exeroot()[source]

Assumes CASEROOT is already set; sets an appropriate EXEROOT (nested inside CASEROOT)

set_rundir()[source]

Assumes CASEROOT is already set; sets an appropriate RUNDIR (nested inside CASEROOT)

set_value(item, value)[source]

Set the value of the given item to the given value

Args:

item (str): variable of interest value (any type): new value for item

CIME.tests.test_case_fake module

This module contains unit tests of CaseFake

class CIME.tests.test_case_fake.TestCaseFake(methodName='runTest')[source]

Bases: unittest.case.TestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

tearDown()[source]

Hook method for deconstructing the test fixture after testing it.

test_create_clone()[source]

CIME.tests.test_user_mod_support module

class CIME.tests.test_user_mod_support.TestUserModSupport(methodName='runTest')[source]

Bases: unittest.case.TestCase

assertResults(expected_user_nl_cpl, expected_shell_commands_result, expected_sourcemod, msg='')[source]

Asserts that the contents of the files in self._caseroot match expectations

If msg is provided, it is printed for some failing assertions

createUserMod(name, include_dirs=None)[source]

Create a user_mods directory with the given name.

This directory is created within self._user_mods_parent_dir

For name=’foo’, it will contain:

  • A user_nl_cpl file with contents: foo

  • A shell_commands file with contents: echo foo >> /PATH/TO/CASEROOT/shell_commands_result

  • A file in _SOURCEMODS named myfile.F90 with contents: foo

If include_dirs is given, it should be a list of strings, giving names of other user_mods directories to include. e.g., if include_dirs is [‘foo1’, ‘foo2’], then this will create a file ‘include_user_mods’ that contains paths to the ‘foo1’ and ‘foo2’ user_mods directories, one per line.

setUp()[source]

Hook method for setting up the test fixture before exercising it.

tearDown()[source]

Hook method for deconstructing the test fixture after testing it.

test_basic()[source]
test_duplicate_includes()[source]

Test multiple includes, where both include the same base mod.

The base mod should only be included once.

test_include()[source]

If there is an included mod, the main one should appear after the included one so that it takes precedence.

test_keepexe()[source]
test_two_applications()[source]

If apply_user_mods is called twice, the second should appear after the first so that it takes precedence.

CIME.tests.test_utils module

class CIME.tests.test_utils.TestIndentStr(methodName='runTest')[source]

Bases: unittest.case.TestCase

Test the indent_string function.

test_indent_string_multiline()[source]

Test the indent_string function with a multi-line string

test_indent_string_singleline()[source]

Test the indent_string function with a single-line string

Module contents