def test_clib_full_names_gmt_library_path_undefined_path_empty( monkeypatch, gmt_lib_names): """ Make sure that clib_full_names() returns a generator with expected names when GMT_LIBRARY_PATH is undefined and PATH is empty. """ with monkeypatch.context() as mpatch: mpatch.delenv("GMT_LIBRARY_PATH", raising=False) mpatch.setenv("PATH", "") lib_fullpaths = clib_full_names() assert isinstance(lib_fullpaths, types.GeneratorType) assert list(lib_fullpaths) == gmt_lib_names
def test_clib_full_names_gmt_library_path_defined_path_empty( monkeypatch, gmt_lib_names, gmt_lib_realpath): """ Make sure that clib_full_names() returns a generator with expected names when GMT_LIBRARY_PATH is defined and PATH is empty. """ with monkeypatch.context() as mpatch: mpatch.setenv("GMT_LIBRARY_PATH", str(PurePath(gmt_lib_realpath).parent)) mpatch.setenv("PATH", "") lib_fullpaths = clib_full_names() assert isinstance(lib_fullpaths, types.GeneratorType) assert list(lib_fullpaths) == [gmt_lib_realpath] + gmt_lib_names
def test_clib_full_names_gmt_library_path_undefined_path_included( monkeypatch, gmt_lib_names, gmt_lib_realpath, gmt_bin_dir): """ Make sure that clib_full_names() returns a generator with expected names when GMT_LIBRARY_PATH is undefined and PATH includes GMT's bin path. """ with monkeypatch.context() as mpatch: mpatch.delenv("GMT_LIBRARY_PATH", raising=False) mpatch.setenv("PATH", gmt_bin_dir) lib_fullpaths = clib_full_names() assert isinstance(lib_fullpaths, types.GeneratorType) # Windows: find_library() searches the library in PATH, so one more npath = 2 if sys.platform == "win32" else 1 assert list( lib_fullpaths) == [gmt_lib_realpath] * npath + gmt_lib_names