def test_update_config(): r"""Test update_config.""" test_cfg = os.path.join(tempfile.gettempdir(), 'test.cfg') assert (not os.path.isfile(test_cfg)) if not tools.is_lang_installed('matlab'): # pragma: no matlab assert_warns(RuntimeWarning, config.update_config, test_cfg) config.update_config(test_cfg) assert (os.path.isfile(test_cfg)) os.remove(test_cfg)
def test_locate_file(): r"""Test file location method.""" # Missing file assert (not config.locate_file('missing_file.fake')) # Single file sdir, spat, sans = make_temp_single() sout = config.locate_file(spat) assert (isinstance(sout, backwards.string_types)) assert_equal(sout, sans[0]) # Multiple files mdir, mpat, mans = make_temp_multiple() with assert_warns(RuntimeWarning): mout = config.locate_file(mpat) assert (isinstance(mout, backwards.string_types)) assert_equal(mout, mans[0])
def test_locate_file(): r"""Test file location method.""" # Missing file assert (not tools.locate_file('missing_file.fake')) assert (not tools.locate_file(['missing_file.fake'])) # Single file sdir, spat, sans = make_temp_single() sout = tools.locate_file(spat, verification_func=os.path.isfile) assert (isinstance(sout, (bytes, str))) assert_equal(sout, sans[0]) # Multiple files mdir, mpat, mans = make_temp_multiple() with assert_warns(RuntimeWarning): mout = tools.locate_file([mpat]) assert (isinstance(mout, (bytes, str))) assert_equal(mout, mans[0])