Skip to content
Snippets Groups Projects
Commit e5b70501 authored by Leo Singer's avatar Leo Singer
Browse files

Fix leaked temporary file in unit tests

parent e15c938f
No related branches found
No related tags found
1 merge request!31Fix leaked temporary file in unit tests
Pipeline #124635 passed
......@@ -9,17 +9,17 @@ from .. import em_bright
def test_source_classification_pe():
f = NamedTemporaryFile()
filename = f.name
with h5py.File(f) as tmp_h5:
data = np.array([(1.2, 1.0, 0.0, 0.0, 100.0), (2.0, 0.5, 0.99, 0.99, 150.0)],
dtype=[('mc', '<f8'), ('q', '<f8'),
('a1', '<f8'), ('a2', '<f8'), ('dist', '<f8')])
tmp_h5.create_dataset(
'lalinference/lalinference_mcmc/posterior_samples',
data=data
)
r = em_bright.source_classification_pe(filename)
with NamedTemporaryFile() as f:
filename = f.name
with h5py.File(f) as tmp_h5:
data = np.array([(1.2, 1.0, 0.0, 0.0, 100.0), (2.0, 0.5, 0.99, 0.99, 150.0)],
dtype=[('mc', '<f8'), ('q', '<f8'),
('a1', '<f8'), ('a2', '<f8'), ('dist', '<f8')])
tmp_h5.create_dataset(
'lalinference/lalinference_mcmc/posterior_samples',
data=data
)
r = em_bright.source_classification_pe(filename)
assert r == (1.0, 1.0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment