Skip to content

Commit

Permalink
Fixing test for python backward compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
RubelMozumder committed Nov 3, 2023
1 parent e616851 commit ebc61c2
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions dev_tools/tests/test_nyaml2nxdl.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import os

from click.testing import CliRunner

from ..nyaml2nxdl import nyaml2nxdl as conv
Expand All @@ -8,18 +6,18 @@

def test_conversion():
root = find_definition_file("NXentry")
result = CliRunner().invoke(conv.launch_tool, ["--input-file", root])
result = CliRunner().invoke(conv.launch_tool, ["--input-file", str(root)])
assert result.exit_code == 0
# Replace suffixes
yaml = root.with_suffix("").with_suffix(".yaml")
yaml = yaml.with_stem(yaml.stem + "_parsed")
result = CliRunner().invoke(conv.launch_tool, ["--input-file", yaml])
yaml = root.with_suffix("").with_suffix(".yaml") # replace .nxdl.xml
yaml = yaml.with_name(yaml.stem + "_parsed.yaml") # extend file name with _parsed
result = CliRunner().invoke(conv.launch_tool, ["--input-file", str(yaml)])
assert result.exit_code == 0
new_root = yaml.with_suffix(".nxdl.xml")
new_root = yaml.with_suffix(".nxdl.xml") # replace yaml
with open(root, encoding="utf-8", mode="r") as tmp_f:
root_content = tmp_f.readlines()
with open(new_root, encoding="utf-8", mode="r") as tmp_f:
new_root_content = tmp_f.readlines()
assert root_content == new_root_content
os.remove(yaml)
os.remove(new_root)
yaml.unlink()
new_root.unlink()

0 comments on commit ebc61c2

Please sign in to comment.