Skip to content

Commit

Permalink
Add test for duplicated input files in merge tool
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnoe committed Sep 4, 2024
1 parent 4de5fc1 commit df6f812
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/ctapipe/tools/tests/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
from pathlib import Path

import numpy as np
import pytest
import tables
from astropy.table import vstack
from astropy.utils.diff import report_diff_values

from ctapipe.core import run_tool
from ctapipe.core import ToolConfigurationError, run_tool
from ctapipe.io import TableLoader
from ctapipe.io.astropy_helpers import read_table
from ctapipe.io.tests.test_astropy_helpers import assert_table_equal
Expand Down Expand Up @@ -188,3 +189,22 @@ def test_muon(tmp_path, dl1_muon_output_file):
assert len(table) == 2 * n_input
assert_table_equal(table[:n_input], input_table)
assert_table_equal(table[n_input:], input_table)


def test_duplicated(tmp_path, dl1_file, dl1_proton_file):
from ctapipe.tools.merge import MergeTool

output = tmp_path / "invalid.dl1.h5"
with pytest.raises(ToolConfigurationError, match="Same file given multiple times"):
run_tool(
MergeTool(),
argv=[
str(dl1_file),
str(dl1_proton_file),
str(dl1_file),
f"--output={output}",
"--overwrite",
],
cwd=tmp_path,
raises=True,
)

0 comments on commit df6f812

Please sign in to comment.