Skip to content

Commit be6ecda

Browse files
committed
doc: changes to tests
1 parent 4600f5d commit be6ecda

File tree

5 files changed

+20
-21
lines changed

5 files changed

+20
-21
lines changed

src/ansys/dpf/core/workflow.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -933,15 +933,11 @@ def view(
933933
name = title
934934

935935
if save_as:
936-
# dot_path = os.path.splitext(str(save_as))[0] + ".dot"
937936
image_path = Path(save_as)
938937
dot_path = image_path.parent / image_path.stem / ".dot"
939-
# image_path = save_as
940938
else:
941-
# dot_path = os.path.join(os.getcwd(), f"{name}.dot")
942939
image_path = Path.cwd() / f"{name}.png"
943940
dot_path = image_path.parent / image_path.stem / ".dot"
944-
# image_path = os.path.join(os.getcwd(), f"{name}.png")
945941

946942
# Create graphviz file of workflow
947943
self.to_graphviz(dot_path)
@@ -951,7 +947,6 @@ def view(
951947
# View workflow
952948
graphviz.view(filepath=image_path)
953949
if not keep_dot_file:
954-
# os.remove(dot_path)
955950
dot_path.unlink()
956951
return image_path
957952

tests/conftest.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
import os
3030
import functools
31+
from pathlib import Path
3132

3233
import psutil
3334
import pytest
@@ -54,10 +55,10 @@
5455

5556
def _get_test_files_directory():
5657
if local_test_repo is False:
57-
test_path = os.path.join(os.path.dirname(os.path.abspath(__file__)))
58-
return os.path.join(test_path, os.pardir, "tests", "testfiles")
58+
test_path = Path(__file__).parent
59+
return str(test_path.joinpath("testfiles"))
5960
else:
60-
return os.path.join(os.environ["AWP_UNIT_TEST_FILES"], "python")
61+
return str(Path(os.environ["AWP_UNIT_TEST_FILES"]).joinpath("python"))
6162

6263

6364
if os.name == "posix":
@@ -94,11 +95,11 @@ def resolve_test_file(basename, additional_path="", is_in_examples=None):
9495
if is_in_examples:
9596
return examples.find_files(getattr(examples, is_in_examples))
9697
else:
97-
test_files_path = _get_test_files_directory()
98-
filename = os.path.join(test_files_path, additional_path, basename)
99-
if not os.path.isfile(filename):
98+
test_files_path = Path(_get_test_files_directory())
99+
filename = test_files_path.joinpath(additional_path, basename)
100+
if not filename.is_file():
100101
raise FileNotFoundError(f"Unable to locate {basename} at {test_files_path}")
101-
return examples.find_files(filename)
102+
return examples.find_files(str(filename))
102103

103104

104105
@pytest.fixture()

tests/entry/conftest.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"""
3030

3131
import os
32+
from pathlib import Path
3233
import functools
3334
import pytest
3435

@@ -54,10 +55,10 @@
5455

5556
def _get_test_files_directory():
5657
if local_test_repo is False:
57-
test_path = os.path.join(os.path.dirname(os.path.abspath(__file__)))
58-
return os.path.join(test_path, os.pardir, "tests", "testfiles")
58+
test_path = Path(__file__).parent
59+
return str(test_path.joinpath("testfiles"))
5960
else:
60-
return os.path.join(os.environ["AWP_UNIT_TEST_FILES"], "python")
61+
return str(Path(os.environ["AWP_UNIT_TEST_FILES"]).joinpath("python"))
6162

6263

6364
if os.name == "posix":

tests/test_animation.py

Lines changed: 3 additions & 2 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

@@ -43,8 +44,8 @@ def remove_gifs(request):
4344
"""Remove GIF once finished."""
4445

4546
def remove_gif():
46-
if os.path.exists(os.path.join(os.getcwd(), gif_name)):
47-
os.remove(os.path.join(os.getcwd(), gif_name))
47+
if Path.cwd().joinpath(gif_name).exists():
48+
Path.cwd().joinpath(gif_name).unlink()
4849

4950
request.addfinalizer(remove_gif)
5051

tests/test_animator.py

Lines changed: 5 additions & 4 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

@@ -42,8 +43,8 @@ def remove_gifs(request):
4243
"""Remove GIF once finished."""
4344

4445
def remove_gif():
45-
if os.path.exists(os.path.join(os.getcwd(), gif_name)):
46-
os.remove(os.path.join(os.getcwd(), gif_name))
46+
if Path.cwd().joinpath(gif_name).exists():
47+
Path.cwd().joinpath(gif_name).unlink()
4748

4849
request.addfinalizer(remove_gif)
4950

@@ -250,5 +251,5 @@ def test_animator_animate_fields_container_cpos(remove_gifs, displacement_fields
250251
off_screen=True,
251252
show_axes=True,
252253
)
253-
assert os.path.isfile(gif_name)
254-
assert os.path.getsize(gif_name) > 6000
254+
assert Path(gif_name).is_file()
255+
assert Path(gif_name).stat().st_size > 6000

0 commit comments

Comments
 (0)