@@ -0,0 +1,2647 @@
+#!/usr/bin/env python%0A#%0A# Tests for the dakota.run_plugin module.%0A#%0A# Call with:%0A#   $ nosetests -sv%0A#%0A# Mark Piper (mark.piper@colorado.edu)%0A%0Aimport os%0Aimport sys%0Aimport shutil%0A# import filecmp%0A# import tempfile%0A# import numpy as np%0A# from numpy.testing import assert_almost_equal%0Afrom nose.tools import raises, with_setup%0Afrom dakota.run_plugin import run_plugin, main%0Afrom dakota.core import Dakota%0Afrom dakota.plugins.hydrotrend import is_installed%0Afrom . import start_dir, data_dir%0A%0A%0A# Global variables -----------------------------------------------------%0A%0Arun_dir = os.getcwd()%0Alocal_config_file = 'config.yaml'%0Aconfig_file = os.path.join(data_dir, local_config_file)%0Alocal_params_file = 'params.in'%0Aparams_file = os.path.join(data_dir, local_params_file)%0Aresults_file = 'results.out'%0A%0A# Fixtures -------------------------------------------------------------%0A%0A%0Adef setup_module():%0A    %22%22%22Called before any tests are performed.%22%22%22%0A    print('%5Cn*** ' + __name__)%0A%0A%0Adef setup():%0A    %22%22%22Called at start of any test using it @with_setup()%22%22%22%0A    global d%0A    d = Dakota.from_file_like(config_file)%0A%0A%0Adef teardown():%0A    %22%22%22Called at end of any test using it @with_setup()%22%22%22%0A    if os.path.exists(results_file):%0A        os.remove(results_file)%0A    if os.path.exists(local_config_file):%0A        os.remove(local_config_file)%0A    if os.path.exists(local_params_file):%0A        os.remove(local_params_file)%0A%0A%0Adef teardown_module():%0A    %22%22%22Called after all tests have completed.%22%22%22%0A    pass%0A%0A# Tests ----------------------------------------------------------------%0A%0A%0A# @with_setup(setup, teardown)%0A# def test_run_plugin():%0A#     %22%22%22Tests run_plugin().%22%22%22%0A#     if is_installed():%0A#         shutil.copy(params_file, run_dir)%0A#         shutil.copy(config_file, run_dir)%0A#         run_plugin(params_file, results_file)%0A%0A%0A@raises(IOError)%0Adef test_run_plugin_unknown_config_file():%0A    %22%22%22Tests run_plugin() fails with unknown config file.%22%22%22%0A    run_plugin(params_file, results_file)%0A%0A%0A@raises(ImportError)%0A@with_setup(setup, teardown)%0Adef test_run_plugin_unknown_module():%0A    %22%22%22Tests run_plugin() fails with unknown module.%22%22%22%0A    d.method.component = 'foo'%0A    d.write_configuration_file(local_config_file)%0A    run_plugin(params_file, results_file)%0A%0A%0A@raises(NameError)%0A@with_setup(setup, teardown)%0Adef test_run_plugin_uninstalled_module():%0A    %22%22%22Tests run_plugin() fails with module that's not installed.%22%22%22%0A    d.write_configuration_file(local_config_file)%0A    os.environ%5B'PATH'%5D = '.'%0A    run_plugin(params_file, results_file)%0A%0A%0A@raises(IndexError)%0Adef test_main_no_args():%0A    %22%22%22Tests main() fails without args.%22%22%22%0A    sys.argv = %5B%5D%0A    main()%0A

Add tests for dakota.run_plugin module