diff --git a/tests/test_data_tree.py b/tests/test_data_tree.py index 5adb68f1fd..10416d38c4 100644 --- a/tests/test_data_tree.py +++ b/tests/test_data_tree.py @@ -209,9 +209,7 @@ def test_write_to_file_remote_data_tree(tmpdir, server_clayer_remote_process): to_fill.list_double = [1.5, 2.5] to_fill.list_string = ["hello", "bye"] data_tree.write_to_txt(str(Path(tmpdir) / "file.txt")) - data_tree = dpf.DataTree.read_from_txt( - str(Path(tmpdir) / "file.txt"), server=server_connected - ) + data_tree = dpf.DataTree.read_from_txt(str(Path(tmpdir) / "file.txt"), server=server_connected) assert data_tree.has("int") assert data_tree.has("double") assert data_tree.has("string") diff --git a/tests/test_examples.py b/tests/test_examples.py index b7989a0a0f..d5764adc91 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -22,7 +22,7 @@ """Verify all examples can be accessed or downloaded""" -import os.path +from pathlib import Path import pytest @@ -152,12 +152,12 @@ def test_find_examples(example, server_type_remote_process): def test_delete_downloaded_files(): - path = examples.download_multi_stage_cyclic_result(return_local_path=True) - assert os.path.exists(path) + path = Path(examples.download_multi_stage_cyclic_result(return_local_path=True)) + assert path.exists() examples.delete_downloads(verbose=False) - assert not os.path.exists(path) - path = examples.download_multi_stage_cyclic_result(return_local_path=True) - assert os.path.exists(path) + assert not path.exists() + path = Path(examples.download_multi_stage_cyclic_result(return_local_path=True)) + assert path.exists() def test_get_example_required_minimum_dpf_version(tmp_path): @@ -197,12 +197,12 @@ def test_get_example_required_minimum_dpf_version(tmp_path): def test_download_easy_statistics(): - assert os.path.exists(examples.download_easy_statistics(return_local_path=True)) + assert Path(examples.download_easy_statistics(return_local_path=True)).exists() def test_download_average_filter_plugin(): - assert os.path.exists(examples.download_average_filter_plugin(return_local_path=True)) + assert Path(examples.download_average_filter_plugin(return_local_path=True)).exists() def test_download_gltf_plugin(): - assert os.path.exists(examples.download_gltf_plugin(return_local_path=True)) + assert Path(examples.download_gltf_plugin(return_local_path=True)).exists() diff --git a/tests/test_launcher.py b/tests/test_launcher.py index 293d4f165d..be99ea4171 100644 --- a/tests/test_launcher.py +++ b/tests/test_launcher.py @@ -21,6 +21,7 @@ # SOFTWARE. import os +from pathlib import Path import pytest import psutil @@ -192,10 +193,10 @@ def test_start_local_wrong_ansys_path(self, server_config): def test_launch_server_full_path(self, server_config): ansys_path = core.misc.get_ansys_path() if os.name == "nt": - path = os.path.join(ansys_path, "aisol", "bin", "winx64") + path = Path(ansys_path) / "aisol" / "bin" / "winx64" else: if server_config.protocol == core.server_factory.CommunicationProtocols.InProcess: - path = os.path.join(ansys_path, "aisol", "dll", "linx64") + path = Path(ansys_path) / "aisol" / "dll" / "linx64" elif ( server_config.protocol == core.server_factory.CommunicationProtocols.gRPC and server_config.legacy is False @@ -204,11 +205,13 @@ def test_launch_server_full_path(self, server_config): # Ans.Dpf.Grpc.sh reside in two different folders return else: - path = os.path.join(ansys_path, "aisol", "bin", "linx64") + path = Path(ansys_path) / "aisol" / "bin" / "linx64" # print("trying to launch on ", path) # print(os.listdir(path)) - server = core.start_local_server(as_global=False, ansys_path=path, config=server_config) + server = core.start_local_server( + as_global=False, ansys_path=str(path), config=server_config + ) assert "server_port" in server.info @@ -219,7 +222,7 @@ def test_start_local_failed_executable(remote_config_server_type): with pytest.raises(FileNotFoundError): path = Path(get_ansys_path()).parent.absolute() - core.start_local_server(ansys_path=path, config=remote_config_server_type) + core.start_local_server(ansys_path=str(path), config=remote_config_server_type) @pytest.mark.skipif(not running_docker, reason="Checks docker start server") diff --git a/tests/test_operator.py b/tests/test_operator.py index 8cfadd185b..b583cf6e05 100644 --- a/tests/test_operator.py +++ b/tests/test_operator.py @@ -25,6 +25,7 @@ import shutil import types import weakref +from pathlib import Path import numpy as np import pytest @@ -446,8 +447,8 @@ def find_mapdl(): try: path = get_ansys_path() if dpf.core.SERVER.os == "nt": - exe = os.path.join(path, "ansys", "bin", "winx64", "ANSYS.exe") - return os.path.isfile(exe) + exe = Path(path).joinpath("ansys", "bin", "winx64", "ANSYS.exe") + return exe.is_file() else: return False @@ -465,8 +466,8 @@ def test_inputs_outputs_datasources_operator(cyclic_ds, server_type): dsout = op.outputs.data_sources() assert dsout is not None assert dsout.result_key == "rst" - path = os.path.join(dsout.result_files[0]) - shutil.rmtree(os.path.dirname(path)) + path = Path(dsout.result_files[0]) + shutil.rmtree(path.parent) def test_subresults_operator(cyclic_lin_rst, cyclic_ds):