CIME.tests package¶
Subpackages¶
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
-
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
-
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
-
set_exeroot
()[source]¶ Assumes CASEROOT is already set; sets an appropriate EXEROOT (nested inside CASEROOT)
-
CIME.tests.custom_assertions_test_status module¶
This module contains a class that extends unittest.TestCase, adding custom assertions that can be used when testing TestStatus.
-
class
CIME.tests.custom_assertions_test_status.
CustomAssertionsTestStatus
(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase
-
assert_core_phases
(output, test_name, fails)[source]¶ Asserts that ‘output’ contains a line for each of the core test phases for the given test_name. All results should be PASS except those given by the fails list, which should be FAILS.
-
assert_num_expected_unexpected_fails
(output, num_expected, num_unexpected)[source]¶ Asserts that the number of occurrences of expected and unexpected fails in ‘output’ matches the given numbers
-
assert_phase_absent
(output, phase, test_name)[source]¶ Asserts that ‘output’ does not contain a status line for the given phase and test_name
-
assert_status_of_phase
(output, status, phase, test_name, xfail=None)[source]¶ Asserts that ‘output’ contains a line showing the given status for the given phase for the given test_name.
‘xfail’ should have one of the following values: - None (the default): assertion passes regardless of whether there is an
EXPECTED/UNEXPECTED string
‘no’: The line should end with the phase, with no additional text after that
‘expected’: After the phase, the line should contain ‘(EXPECTED FAILURE)’
‘unexpected’: After the phase, the line should contain ‘(UNEXPECTED’
-
CIME.tests.test_case_fake module¶
This module contains unit tests of CaseFake
CIME.tests.test_cs_status module¶
-
class
CIME.tests.test_cs_status.
TestCsStatus
(methodName='runTest')[source]¶ Bases:
CIME.tests.custom_assertions_test_status.CustomAssertionsTestStatus
-
create_test_dir
(test_dir)[source]¶ Creates the given test directory under testroot.
Returns the full path to the created test directory.
-
static
create_test_status_core_passes
(test_dir_path, test_name)[source]¶ Creates a TestStatus file in the given path, with PASS status for all core phases
-
set_last_core_phase_to_fail
(test_dir_path, test_name)[source]¶ Sets the last core phase to FAIL
Returns the name of this phase
-
static
set_phase_to_status
(test_dir_path, test_name, phase, status)[source]¶ Sets the given phase to the given status for this test
-
test_count_fails
()[source]¶ Test the count of fails with three tests
For first phase of interest: First test FAILs, second PASSes, third FAILs; count should be 2, and this phase should not appear individually for each test.
For second phase of interest: First test PASSes, second PASSes, third FAILs; count should be 1, and this phase should not appear individually for each test.
-
CIME.tests.test_custom_assertions_test_status module¶
This module contains unit tests of CustomAssertionsTestStatus
-
class
CIME.tests.test_custom_assertions_test_status.
TestCustomAssertions
(methodName='runTest')[source]¶ Bases:
CIME.tests.custom_assertions_test_status.CustomAssertionsTestStatus
-
test_assertCorePhases_missingPhase_fails
()[source]¶ assert_core_phases fails if there is a missing phase
-
test_assertCorePhases_wrongStatus_fails
()[source]¶ assert_core_phases fails if a phase has the wrong status
-
test_assertPhaseAbsent_fails
()[source]¶ assert_phase_absent should fail when the phase is present for the given test_name
-
test_assertPhaseAbsent_passes
()[source]¶ assert_phase_absent should pass when the phase is absent for the given test_name
-
test_assertStatusOfPhase_withExtra_passes
()[source]¶ Make sure assert_status_of_phase passes when there is some extra text at the end of the line
-
test_assertStatusOfPhase_xfailExpected_fails
()[source]¶ assert_status_of_phase should fail when xfail=’expected’ but the line does NOT contain the EXPECTED comment
-
test_assertStatusOfPhase_xfailExpected_passes
()[source]¶ assert_status_of_phase should pass when xfail=’expected’ and the line contains the EXPECTED comment
-
test_assertStatusOfPhase_xfailNo_fails
()[source]¶ assert_status_of_phase should fail when xfail=’no’ but the line contains the EXPECTED comment
-
test_assertStatusOfPhase_xfailNo_passes
()[source]¶ assert_status_of_phase should pass when xfail=’no’ and there is no EXPECTED/UNEXPECTED on the line
-
CIME.tests.test_test_status module¶
-
class
CIME.tests.test_test_status.
TestTestStatus
(methodName='runTest')[source]¶ Bases:
CIME.tests.custom_assertions_test_status.CustomAssertionsTestStatus
-
test_psdump_oneCorePhaseFailsAbsentFromXFails
()[source]¶ One phase fails. There is an expected fails list, but that phase is not in it.
-
test_psdump_oneCorePhaseFailsInXFails
()[source]¶ One phase fails. That phase is in the expected fails list.
-
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.
-
test_duplicate_includes
()[source]¶ Test multiple includes, where both include the same base mod.
The base mod should only be included once.
-