Skip to content

Commit

Permalink
better path refs
Browse files Browse the repository at this point in the history
  • Loading branch information
simbilod committed Sep 12, 2024
1 parent fc8a8b0 commit 15f996f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
1 change: 1 addition & 0 deletions meshwell/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
class Path:
module = module_path
repo = repo_path
references = repo_path / "tests" / "references"


PATH = Path()
Expand Down
7 changes: 2 additions & 5 deletions meshwell/utils.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
from difflib import unified_diff
from pathlib import Path
from meshwell.config import PATH


def compare_meshes(meshfile: Path):
meshfile1 = meshfile
meshfile2 = (
meshfile.parent
/ "references"
/ (str(meshfile.with_suffix("")) + ".reference.msh")
)
meshfile2 = PATH.references / (str(meshfile.with_suffix("")) + ".reference.msh")

with open(str(meshfile1)) as f:
expected_lines = f.readlines()
Expand Down
8 changes: 4 additions & 4 deletions tests/generate_references.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import os
import pytest
from meshwell.config import PATH

if __name__ == "__main__":
# Delete existing references
exec_dir_name = "./"
save_dir_name = "./references/"
test = os.listdir(save_dir_name)
test = os.listdir(PATH.references)

for item in test:
if item.endswith(".msh"):
os.remove(os.path.join(save_dir_name, item))
os.remove(os.path.join(PATH.references, item))

# Run the tests to generate the files
pytest.main()
Expand All @@ -18,4 +18,4 @@
test = os.listdir(exec_dir_name)
for item in test:
if item.endswith(".msh"):
os.rename(item, f"{save_dir_name}/{item[:-4]}.reference.msh")
os.rename(item, PATH.references / f"{item[:-4]}.reference.msh")

0 comments on commit 15f996f

Please sign in to comment.