Skip to content

Commit

Permalink
Add gzip test and reread test
Browse files Browse the repository at this point in the history
  • Loading branch information
APN-Pucky committed Feb 20, 2024
1 parent b692b7f commit 61b28a5
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/test_lhe_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,41 @@ def test_write_lhe():
</event>
</LesHouchesEvents>"""
)


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)

0 comments on commit 61b28a5

Please sign in to comment.