def test_getkernelfilepath_nodir(): '''Test that an appropriate exception is raised if the specified directory does not exist. ''' with pytest.raises(ParseError) as excinfo: _ = get_kernel_filepath("test_mod", "non/existant/file/path", None) assert ("Supplied kernel search path does not exist or cannot be " "read") in str(excinfo.value)
def test_getkernelfilepath_caseinsensitive1(tmpdir): '''Test that a case insensitive match is performed when searching for kernels with a supplied kernel search path. ''' os.mkdir(str(tmpdir.join("tmp"))) filename = str(tmpdir.join("tmp", "test_mod.f90")) ffile = open(filename, "w") ffile.write("") ffile.close() result = get_kernel_filepath("TEST_MOD", str(tmpdir), None) assert "tmp" in result assert "test_mod.f90" in result
def test_getkernelfilepath_multifile(tmpdir): '''Test that an appropriate exception is raised if more than one file matches when searching for kernels. ''' filename = str(tmpdir.join("test_mod.f90")) ffile = open(filename, "w") ffile.write("") ffile.close() os.mkdir(str(tmpdir.join("tmp"))) filename = str(tmpdir.join("tmp", "test_mod.f90")) ffile = open(filename, "w") ffile.write("") ffile.close() with pytest.raises(ParseError) as excinfo: _ = get_kernel_filepath("test_mod", str(tmpdir), None) assert ("More than one match for kernel file 'test_mod.[fF]90' " "found!") in str(excinfo.value)