Skip to content

Commit 8d41688

Browse files
committed
doc: modified more test files
1 parent 79b8faf commit 8d41688

File tree

4 files changed

+23
-21
lines changed

4 files changed

+23
-21
lines changed

tests/test_data_tree.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,7 @@ def test_write_to_file_remote_data_tree(tmpdir, server_clayer_remote_process):
209209
to_fill.list_double = [1.5, 2.5]
210210
to_fill.list_string = ["hello", "bye"]
211211
data_tree.write_to_txt(str(Path(tmpdir) / "file.txt"))
212-
data_tree = dpf.DataTree.read_from_txt(
213-
str(Path(tmpdir) / "file.txt"), server=server_connected
214-
)
212+
data_tree = dpf.DataTree.read_from_txt(str(Path(tmpdir) / "file.txt"), server=server_connected)
215213
assert data_tree.has("int")
216214
assert data_tree.has("double")
217215
assert data_tree.has("string")

tests/test_examples.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
"""Verify all examples can be accessed or downloaded"""
2424

25-
import os.path
25+
from pathlib import Path
2626

2727
import pytest
2828

@@ -152,12 +152,12 @@ def test_find_examples(example, server_type_remote_process):
152152

153153

154154
def test_delete_downloaded_files():
155-
path = examples.download_multi_stage_cyclic_result(return_local_path=True)
156-
assert os.path.exists(path)
155+
path = Path(examples.download_multi_stage_cyclic_result(return_local_path=True))
156+
assert path.exists()
157157
examples.delete_downloads(verbose=False)
158-
assert not os.path.exists(path)
159-
path = examples.download_multi_stage_cyclic_result(return_local_path=True)
160-
assert os.path.exists(path)
158+
assert not path.exists()
159+
path = Path(examples.download_multi_stage_cyclic_result(return_local_path=True))
160+
assert path.exists()
161161

162162

163163
def test_get_example_required_minimum_dpf_version(tmp_path):
@@ -197,12 +197,12 @@ def test_get_example_required_minimum_dpf_version(tmp_path):
197197

198198

199199
def test_download_easy_statistics():
200-
assert os.path.exists(examples.download_easy_statistics(return_local_path=True))
200+
assert Path(examples.download_easy_statistics(return_local_path=True)).exists()
201201

202202

203203
def test_download_average_filter_plugin():
204-
assert os.path.exists(examples.download_average_filter_plugin(return_local_path=True))
204+
assert Path(examples.download_average_filter_plugin(return_local_path=True)).exists()
205205

206206

207207
def test_download_gltf_plugin():
208-
assert os.path.exists(examples.download_gltf_plugin(return_local_path=True))
208+
assert Path(examples.download_gltf_plugin(return_local_path=True)).exists()

tests/test_launcher.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# SOFTWARE.
2222

2323
import os
24+
from pathlib import Path
2425

2526
import pytest
2627
import psutil
@@ -192,10 +193,10 @@ def test_start_local_wrong_ansys_path(self, server_config):
192193
def test_launch_server_full_path(self, server_config):
193194
ansys_path = core.misc.get_ansys_path()
194195
if os.name == "nt":
195-
path = os.path.join(ansys_path, "aisol", "bin", "winx64")
196+
path = Path(ansys_path) / "aisol" / "bin" / "winx64"
196197
else:
197198
if server_config.protocol == core.server_factory.CommunicationProtocols.InProcess:
198-
path = os.path.join(ansys_path, "aisol", "dll", "linx64")
199+
path = Path(ansys_path) / "aisol" / "dll" / "linx64"
199200
elif (
200201
server_config.protocol == core.server_factory.CommunicationProtocols.gRPC
201202
and server_config.legacy is False
@@ -204,11 +205,13 @@ def test_launch_server_full_path(self, server_config):
204205
# Ans.Dpf.Grpc.sh reside in two different folders
205206
return
206207
else:
207-
path = os.path.join(ansys_path, "aisol", "bin", "linx64")
208+
path = Path(ansys_path) / "aisol" / "bin" / "linx64"
208209

209210
# print("trying to launch on ", path)
210211
# print(os.listdir(path))
211-
server = core.start_local_server(as_global=False, ansys_path=path, config=server_config)
212+
server = core.start_local_server(
213+
as_global=False, ansys_path=str(path), config=server_config
214+
)
212215
assert "server_port" in server.info
213216

214217

@@ -219,7 +222,7 @@ def test_start_local_failed_executable(remote_config_server_type):
219222

220223
with pytest.raises(FileNotFoundError):
221224
path = Path(get_ansys_path()).parent.absolute()
222-
core.start_local_server(ansys_path=path, config=remote_config_server_type)
225+
core.start_local_server(ansys_path=str(path), config=remote_config_server_type)
223226

224227

225228
@pytest.mark.skipif(not running_docker, reason="Checks docker start server")

tests/test_operator.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import shutil
2626
import types
2727
import weakref
28+
from pathlib import Path
2829

2930
import numpy as np
3031
import pytest
@@ -446,8 +447,8 @@ def find_mapdl():
446447
try:
447448
path = get_ansys_path()
448449
if dpf.core.SERVER.os == "nt":
449-
exe = os.path.join(path, "ansys", "bin", "winx64", "ANSYS.exe")
450-
return os.path.isfile(exe)
450+
exe = Path(path).joinpath("ansys", "bin", "winx64", "ANSYS.exe")
451+
return exe.is_file()
451452
else:
452453
return False
453454

@@ -465,8 +466,8 @@ def test_inputs_outputs_datasources_operator(cyclic_ds, server_type):
465466
dsout = op.outputs.data_sources()
466467
assert dsout is not None
467468
assert dsout.result_key == "rst"
468-
path = os.path.join(dsout.result_files[0])
469-
shutil.rmtree(os.path.dirname(path))
469+
path = Path(dsout.result_files[0])
470+
shutil.rmtree(path.parent)
470471

471472

472473
def test_subresults_operator(cyclic_lin_rst, cyclic_ds):

0 commit comments

Comments
 (0)