Skip to content

Commit

Permalink
move order of args in testing
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaspie committed Jul 10, 2024
1 parent 0fd6657 commit da5df5b
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/pynxtools/testing/nexus_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ReaderTest:
"""Generic test for reader plugins."""

def __init__(
self, nxdl, reader_name, files_or_dir, ref_log_file, tmp_path, caplog
self, nxdl, reader_name, files_or_dir, tmp_path, caplog, ref_log_file=None
) -> None:
"""Initialize the test object.
Expand All @@ -53,22 +53,24 @@ def __init__(
files_or_dir : str
List of input files or full path string to the example data directory that contains all the files
required for running the data conversion through the reader.
ref_log_file : str
Full path string to the reference log file generated from the same
set of input files.
tmp_path : pathlib.PosixPath
Pytest fixture variable, used to clean up the files generated during the test.
caplog : _pytest.logging.LogCaptureFixture
Pytest fixture variable, used to capture the log messages during the test.
ref_log_file : str
Full path string to the reference log file generated from the same
set of input files in files_or_dir. This can also be parsed automatically if files_or_dir
is the full path string to the example data directory and there is only one reference
log file.
"""

self.nxdl = nxdl
self.reader_name = reader_name
self.reader = get_reader(self.reader_name)
self.files_or_dir = files_or_dir
self.ref_log_file = ref_log_file
self.tmp_path = tmp_path
self.caplog = caplog
self.ref_log_file = ref_log_file
self.created_nexus = f"{tmp_path}/{os.sep}/output.nxs"

def convert_to_nexus(
Expand All @@ -95,7 +97,9 @@ def convert_to_nexus(
][0]
assert self.ref_log_file, "Reference nexus .log file not found"

input_files = [file for file in example_files if not file.endswith(".nxs")]
input_files = [
file for file in example_files if not file.endswith((".nxs", ".log"))
]

assert (
self.nxdl in self.reader.supported_nxdls
Expand Down Expand Up @@ -140,8 +144,8 @@ def check_reproducibility_of_nexus(self):
"DEBUG - value: v",
"DEBUG - value: https://github.com/FAIRmat-NFDI/nexus_definitions/blob/",
]
gen_log = get_log_file(self.created_nexus, "gen_nexus.log", self.tmp_path)
with open(gen_log, "r", encoding="utf-8") as gen, open(
gen_log_file = get_log_file(self.created_nexus, "gen_nexus.log", self.tmp_path)
with open(gen_log_file, "r", encoding="utf-8") as gen, open(
self.ref_log_file, "r", encoding="utf-8"
) as ref:
gen_lines = gen.readlines()
Expand Down

0 comments on commit da5df5b

Please sign in to comment.