diff --git a/tests/test_lhe_writer.py b/tests/test_lhe_writer.py index ee9ecd28..727d4161 100644 --- a/tests/test_lhe_writer.py +++ b/tests/test_lhe_writer.py @@ -197,3 +197,41 @@ def test_write_lhe(): """ ) + + +def test_write_lhe_twice(tmpdir): + file1 = tmpdir.join("test1.lhe") + file2 = tmpdir.join("test2.lhe") + + init = pylhe.read_lhe_init(TEST_FILE_LHE_v3) + events = pylhe.read_lhe_with_attributes(TEST_FILE_LHE_v3) + # single test event + events = [next(events)] + + # write the file + pylhe.write_lhe_file(init, events, filepath=file1.strpath) + + # read it again + init = pylhe.read_lhe_init(file1) + events = pylhe.read_lhe_with_attributes(file1) + + # write it again + pylhe.write_lhe_file(init, events, filepath=file2.strpath) + + # assert that the files are the same + assert file1.read() == file2.read() + + +def test_write_lhe_gzip(tmpdir): + file1 = tmpdir.join("test1.lhe.gz") + + init = pylhe.read_lhe_init(TEST_FILE_LHE_v3) + events = pylhe.read_lhe_with_attributes(TEST_FILE_LHE_v3) + # single test event + events = [next(events)] + + # write the file + pylhe.write_lhe_file(init, events, filepath=file1.strpath, gz=True) + + # read it again + init = pylhe.read_lhe_init(file1)