CIME.tests package
Submodules
CIME.tests.base module
- class CIME.tests.base.BaseTestCase(methodName='runTest')[source]
Bases:
TestCase
- FAST_ONLY = None
- GLOBAL_TIMEOUT = None
- MACHINE = None
- NO_BATCH = None
- NO_CMAKE = None
- NO_FORTRAN_RUN = None
- NO_TEARDOWN = None
- SCRIPT_DIR = '/home/runner/work/cime/cime/scripts'
- TEST_COMPILER = None
- TEST_MPILIB = None
- TEST_ROOT = None
- TOOLS_DIR = '/home/runner/work/cime/cime/CIME/Tools'
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:
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.scripts_regression_tests module
Script containing CIME python regression test suite. This suite should be run to confirm overall CIME correctness.
CIME.tests.test_sys_bless_tests_results module
- class CIME.tests.test_sys_bless_tests_results.TestBlessTestResults(methodName='runTest')[source]
Bases:
BaseTestCase
CIME.tests.test_sys_build_system module
- class CIME.tests.test_sys_build_system.TestBuildSystem(methodName='runTest')[source]
Bases:
BaseTestCase
CIME.tests.test_sys_cime_case module
- class CIME.tests.test_sys_cime_case.TestCimeCase(methodName='runTest')[source]
Bases:
BaseTestCase
CIME.tests.test_sys_cime_performance module
- class CIME.tests.test_sys_cime_performance.TestCimePerformance(methodName='runTest')[source]
Bases:
BaseTestCase
CIME.tests.test_sys_create_newcase module
- class CIME.tests.test_sys_create_newcase.TestCreateNewcase(methodName='runTest')[source]
Bases:
BaseTestCase
- classmethod setUpClass()[source]
Hook method for setting up class fixture before running tests in the class.
- classmethod tearDownClass()[source]
Hook method for deconstructing the class fixture after running all tests in the class.
CIME.tests.test_sys_full_system module
- class CIME.tests.test_sys_full_system.TestFullSystem(methodName='runTest')[source]
Bases:
BaseTestCase
CIME.tests.test_sys_grid_generation module
- class CIME.tests.test_sys_grid_generation.TestGridGeneration(methodName='runTest')[source]
Bases:
BaseTestCase
- classmethod setUpClass()[source]
Hook method for setting up class fixture before running tests in the class.
CIME.tests.test_sys_jenkins_generic_job module
- class CIME.tests.test_sys_jenkins_generic_job.TestJenkinsGenericJob(methodName='runTest')[source]
Bases:
BaseTestCase
CIME.tests.test_sys_manage_and_query module
- class CIME.tests.test_sys_manage_and_query.TestManageAndQuery(methodName='runTest')[source]
Bases:
BaseTestCase
Tests various scripts to manage and query xml files
- test_query_testlists_count_runs()[source]
Make sure that query_testlists runs successfully with the –count argument
- test_query_testlists_define_testtypes_runs()[source]
Make sure that query_testlists runs successfully with the –define-testtypes argument
CIME.tests.test_sys_query_config module
- class CIME.tests.test_sys_query_config.TestQueryConfig(methodName='runTest')[source]
Bases:
BaseTestCase
CIME.tests.test_sys_run_restart module
CIME.tests.test_sys_save_timings module
CIME.tests.test_sys_single_submit module
- class CIME.tests.test_sys_single_submit.TestSingleSubmit(methodName='runTest')[source]
Bases:
BaseTestCase
CIME.tests.test_sys_test_scheduler module
- class CIME.tests.test_sys_test_scheduler.TestTestScheduler(methodName='runTest')[source]
Bases:
BaseTestCase
CIME.tests.test_sys_unittest module
- class CIME.tests.test_sys_unittest.TestUnitTest(methodName='runTest')[source]
Bases:
BaseTestCase
- classmethod setUpClass()[source]
Hook method for setting up class fixture before running tests in the class.
CIME.tests.test_sys_user_concurrent_mods module
- class CIME.tests.test_sys_user_concurrent_mods.TestUserConcurrentMods(methodName='runTest')[source]
Bases:
BaseTestCase
CIME.tests.test_sys_wait_for_tests module
- class CIME.tests.test_sys_wait_for_tests.TestWaitForTests(methodName='runTest')[source]
Bases:
BaseTestCase
CIME.tests.test_unit_aprun module
CIME.tests.test_unit_baselines_performance module
- class CIME.tests.test_unit_baselines_performance.TestUnitBaselinesPerformance(methodName='runTest')[source]
Bases:
TestCase
- test_perf_compare_memory_baseline(get_latest_cpl_logs, read_baseline_file, get_cpl_mem_usage)[source]
- test_perf_compare_memory_baseline_above_threshold(get_latest_cpl_logs, read_baseline_file, get_cpl_mem_usage)[source]
- test_perf_compare_memory_baseline_no_baseline(get_latest_cpl_logs, read_baseline_file, get_cpl_mem_usage)[source]
- test_perf_compare_memory_baseline_no_baseline_file(get_latest_cpl_logs, read_baseline_file, get_cpl_mem_usage)[source]
- test_perf_compare_memory_baseline_no_tolerance(get_latest_cpl_logs, read_baseline_file, get_cpl_mem_usage)[source]
- test_perf_compare_memory_baseline_not_enough_samples(get_latest_cpl_logs, read_baseline_file, get_cpl_mem_usage)[source]
- test_perf_compare_throughput_baseline(get_latest_cpl_logs, read_baseline_file, _perf_get_throughput)[source]
- test_perf_compare_throughput_baseline_above_threshold(get_latest_cpl_logs, read_baseline_file, _perf_get_throughput)[source]
- test_perf_compare_throughput_baseline_no_baseline(get_latest_cpl_logs, read_baseline_file, _perf_get_throughput)[source]
- test_perf_compare_throughput_baseline_no_baseline_file(get_latest_cpl_logs, read_baseline_file, _perf_get_throughput)[source]
- test_perf_compare_throughput_baseline_no_tolerance(get_latest_cpl_logs, read_baseline_file, _perf_get_throughput)[source]
CIME.tests.test_unit_bless_test_results module
- class CIME.tests.test_unit_bless_test_results.TestUnitBlessTestResults(methodName='runTest')[source]
Bases:
TestCase
- test_baseline_name_none(get_test_status_files, TestStatus, Case, bless_namelists, get_current_branch)[source]
- test_bless_memory_only(get_test_status_files, TestStatus, Case, _bless_memory, _bless_throughput)[source]
- test_bless_tests_results_fail(get_test_status_files, TestStatus, Case, bless_namelists, bless_history, _bless_throughput, _bless_memory)[source]
- test_bless_tests_results_homme(get_test_status_files, TestStatus, Case, bless_namelists, bless_history, _bless_throughput, _bless_memory)[source]
- test_bless_throughput_file_not_found_error(perf_compare_throughput_baseline, perf_write_baseline)[source]
- test_bless_throughput_only(get_test_status_files, TestStatus, Case, _bless_memory, _bless_throughput)[source]
CIME.tests.test_unit_case module
- class CIME.tests.test_unit_case.TestCase(methodName='runTest')[source]
Bases:
TestCase
- test_copy(getuser, getfqdn, configure, create_caseroot, apply_user_mods, set_lookup_value, lock_file, strftime, read_xml)[source]
CIME.tests.test_unit_case_fake module
This module contains unit tests of CaseFake
CIME.tests.test_unit_case_run module
CIME.tests.test_unit_case_setup module
CIME.tests.test_unit_compare_test_results module
This module contains unit tests for compare_test_results
CIME.tests.test_unit_compare_two module
This module contains unit tests of the core logic in SystemTestsCompareTwo.
- class CIME.tests.test_unit_compare_two.Call(method, arguments)
Bases:
tuple
- arguments
Alias for field number 1
- method
Alias for field number 0
- class CIME.tests.test_unit_compare_two.SystemTestsCompareTwoFake(case1, run_one_suffix='base', run_two_suffix='test', separate_builds=False, multisubmit=False, case2setup_raises_exception=False, run_one_should_pass=True, run_two_should_pass=True, compare_should_pass=True)[source]
Bases:
SystemTestsCompareTwo
- run_indv(suffix='base', st_archive=False, submit_resubmits=None, keep_init_generated_files=False)[source]
This fake implementation appends to the log and raises an exception if it’s supposed to
Note that the Call object appended to the log has the current CASE name in addition to the method arguments. (This is mainly to ensure that the proper suffix is used for the proper case, but this extra check can be removed if it’s a maintenance problem.)
CIME.tests.test_unit_config module
CIME.tests.test_unit_cs_status module
- class CIME.tests.test_unit_cs_status.TestCsStatus(methodName='runTest')[source]
Bases:
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_unit_custom_assertions_test_status module
This module contains unit tests of CustomAssertionsTestStatus
- class CIME.tests.test_unit_custom_assertions_test_status.TestCustomAssertions(methodName='runTest')[source]
Bases:
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_unit_doctest module
- class CIME.tests.test_unit_doctest.TestDocs(methodName='runTest')[source]
Bases:
BaseTestCase
CIME.tests.test_unit_expected_fails_file module
CIME.tests.test_unit_grids module
This module tests some functionality of CIME.XML.grids
- class CIME.tests.test_unit_grids.TestComponentGrids(methodName='runTest')[source]
Bases:
TestCase
Tests the _ComponentGrids helper class defined in CIME.XML.grids
- test_check_num_elements_right_ndomains()[source]
With the right number of domains for a component, check_num_elements should pass
- test_check_num_elements_right_nmaps()[source]
With the right number of maps between two components, check_num_elements should pass
- class CIME.tests.test_unit_grids.TestGrids(methodName='runTest')[source]
Bases:
TestCase
Tests some functionality of CIME.XML.grids
Note that much of the functionality of CIME.XML.grids is NOT covered here
- assert_grid_info_f09_g17(grid_info)[source]
Asserts that expected grid info is present and correct when using _MODEL_GRID_F09_G17
- class CIME.tests.test_unit_grids.TestGridsFunctions(methodName='runTest')[source]
Bases:
TestCase
Tests helper functions defined in CIME.XML.grids
These tests are in a separate class to avoid the unnecessary setUp and tearDown function of the main test class.
- test_add_grid_info_existing_with_value_for_multiple()[source]
Test of _add_grid_info when the given key already exists and value_for_multiple is provided
CIME.tests.test_unit_hist_utils module
CIME.tests.test_unit_locked_files module
CIME.tests.test_unit_nmlgen module
CIME.tests.test_unit_paramgen module
This module tests some functionality of CIME.ParamGen.paramgen’s ParamGen class
- class CIME.tests.test_unit_paramgen.DummyCase[source]
Bases:
object
A dummy Case class that mimics CIME class objects’ get_value method.
- class CIME.tests.test_unit_paramgen.TestParamGen(methodName='runTest')[source]
Bases:
TestCase
Tests some basic functionality of the CIME.ParamGen.paramgen’s ParamGen class
- test_match()[source]
Tests the default behavior of returning the last match and the optional behavior of returning the first match.
- test_outer_guards()[source]
Tests the reduce method on data with outer guards enclosing parameter definitions.
- class CIME.tests.test_unit_paramgen.TestParamGenXmlConstructor(methodName='runTest')[source]
Bases:
TestCase
A unit test class for testing ParamGen’s xml constructor.
- test_duplicate_entry_error()[source]
Test to make sure duplicate ids raise the correct error when the “no_duplicates” flag is True.
CIME.tests.test_unit_system_tests module
- class CIME.tests.test_unit_system_tests.TestUnitSystemTests(methodName='runTest')[source]
Bases:
TestCase
- test_check_for_memleak(get_latest_cpl_logs, perf_get_memory_list, append_testlog, load_coupler_customization)[source]
- test_check_for_memleak_found(get_latest_cpl_logs, perf_get_memory_list, append_testlog, load_coupler_customization)[source]
- test_check_for_memleak_not_enough_samples(get_latest_cpl_logs, perf_get_memory_list, append_testlog, load_coupler_customization)[source]
CIME.tests.test_unit_system_tests_mvk module
- class CIME.tests.test_unit_system_tests_mvk.TestSystemTestsMVK(methodName='runTest')[source]
Bases:
TestCase
- CIME.tests.test_unit_system_tests_mvk.create_complex_case(case_name, temp_dir, run_dir, baseline_dir, compare_baseline=False, mock_evv_output=False)[source]
CIME.tests.test_unit_test_status module
- class CIME.tests.test_unit_test_status.TestTestStatus(methodName='runTest')[source]
Bases:
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_unit_two_link_to_case2_output module
This module contains unit tests of the method SystemTestsCompareTwo._link_to_case2_output
- class CIME.tests.test_unit_two_link_to_case2_output.SystemTestsCompareTwoFake(case1, run_two_suffix='test')[source]
Bases:
SystemTestsCompareTwo
- class CIME.tests.test_unit_two_link_to_case2_output.TestLinkToCase2Output(methodName='runTest')[source]
Bases:
TestCase
CIME.tests.test_unit_user_mod_support module
- class CIME.tests.test_unit_user_mod_support.TestUserModSupport(methodName='runTest')[source]
Bases:
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.
CIME.tests.test_unit_user_nl_utils module
- class CIME.tests.test_unit_user_nl_utils.TestUserNLCopier(methodName='runTest')[source]
Bases:
TestCase
- assertFileContentsEqual(expected, filepath, msg=None)[source]
Asserts that the contents of the file given by ‘filepath’ are equal to the string given by ‘expected’. ‘msg’ gives an optional message to be printed if the assertion fails.
- write_user_nl_file(component, contents, suffix='')[source]
Write contents to a user_nl file in the case directory. Returns the basename (i.e., not the full path) of the file that is created.
For a component foo, with the default suffix of ‘’, the file name will be user_nl_foo
If the suffix is ‘_0001’, the file name will be user_nl_foo_0001
CIME.tests.test_unit_utils module
- class CIME.tests.test_unit_utils.TestFileContainsPythonFunction(methodName='runTest')[source]
Bases:
TestCase
Tests of file_contains_python_function
- create_test_file(contents)[source]
Creates a test file with the given contents, and returns the path to that file
- class CIME.tests.test_unit_utils.TestIndentStr(methodName='runTest')[source]
Bases:
TestCase
Test the indent_string function.
- class CIME.tests.test_unit_utils.TestLineDefinesPythonFunction(methodName='runTest')[source]
Bases:
TestCase
Tests of _line_defines_python_function
- test_def_foo_no_parens()[source]
Test of a def of the function of interest, but without parentheses
- test_def_foo_space()[source]
Test of a def of the function of interest, with an extra space before the parentheses
- test_import_foo_space()[source]
Test of an import of the function of interest, with trailing spaces
CIME.tests.test_unit_xml_archive_base module
CIME.tests.test_unit_xml_env_batch module
- class CIME.tests.test_unit_xml_env_batch.TestXMLEnvBatch(methodName='runTest')[source]
Bases:
TestCase
- test_set_job_defaults_honor_walltimemax(get_default_queue, select_best_queue, get_queue_specs, text)[source]
- test_set_job_defaults_honor_walltimemin(get_default_queue, select_best_queue, get_queue_specs, text)[source]
- test_set_job_defaults_user_walltime(get_default_queue, select_best_queue, get_queue_specs, text)[source]
- test_set_job_defaults_walltimedef(get_default_queue, select_best_queue, get_queue_specs, text)[source]
- test_set_job_defaults_walltimemax_none(get_default_queue, select_best_queue, get_queue_specs, text)[source]
CIME.tests.test_unit_xml_env_mach_specific module
CIME.tests.test_unit_xml_grids module
CIME.tests.test_unit_xml_machines module
CIME.tests.test_unit_xml_namelist_definition module
CIME.tests.test_unit_xml_tests module
CIME.tests.utils module
- class CIME.tests.utils.CMakeTester(parent, cmake_string)[source]
Bases:
object
Helper class for checking CMake output.
Public methods: __init__ query_var assert_variable_equals assert_variable_matches
- assert_variable_equals(var_name, value, env=None, var=None)[source]
Assert that a variable in the CMakeLists has a given value.
Arguments: var_name - Name of variable to check. value - The string that the variable value should be equal to. env - Optional. Dict of environment variables to set when calling cmake. var - Optional. Dict of CMake variables to set when calling cmake.
- assert_variable_matches(var_name, regex, env=None, var=None)[source]
Assert that a variable in the CMkeLists matches a regex.
Arguments: var_name - Name of variable to check. regex - The regex to match. env - Optional. Dict of environment variables to set when calling cmake. var - Optional. Dict of CMake variables to set when calling cmake.
- query_var(var_name, env, var)[source]
Request the value of a variable in Macros.cmake, as a string.
Arguments: var_name - Name of the variable to query. env - A dict containing extra environment variables to set when calling
cmake.
var - A dict containing extra CMake variables to set when calling cmake.
- class CIME.tests.utils.MakefileTester(parent, make_string)[source]
Bases:
object
Helper class for checking Makefile output.
Public methods: __init__ query_var assert_variable_equals assert_variable_matches
- assert_variable_equals(var_name, value, env=None, var=None)[source]
Assert that a variable in the Makefile has a given value.
Arguments: var_name - Name of variable to check. value - The string that the variable value should be equal to. env - Optional. Dict of environment variables to set when calling make. var - Optional. Dict of make variables to set when calling make.
- assert_variable_matches(var_name, regex, env=None, var=None)[source]
Assert that a variable in the Makefile matches a regex.
Arguments: var_name - Name of variable to check. regex - The regex to match. env - Optional. Dict of environment variables to set when calling make. var - Optional. Dict of make variables to set when calling make.
- query_var(var_name, env, var)[source]
Request the value of a variable in the Makefile, as a string.
Arguments: var_name - Name of the variable to query. env - A dict containing extra environment variables to set when calling
make.
- var - A dict containing extra make variables to set when calling make.
- (The distinction between env and var actually matters only for
CMake, though.)
- class CIME.tests.utils.MockMachines(name, os_)[source]
Bases:
object
A mock version of the Machines object to simplify testing.