From 797d4e6fbdbcf1839b25f66034d8426653b630b9 Mon Sep 17 00:00:00 2001 From: Hans Dembinski Date: Thu, 10 Oct 2024 14:30:56 +0200 Subject: [PATCH] fix --- src/pyhepmc/view.py | 1 + tests/test_view.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pyhepmc/view.py b/src/pyhepmc/view.py index 3a332a7..57ec2c8 100644 --- a/src/pyhepmc/view.py +++ b/src/pyhepmc/view.py @@ -255,6 +255,7 @@ def savefig( except ValueError: if p.exists(): p.unlink() + raise return # if we arrive here, fname is a file-like object diff --git a/tests/test_view.py b/tests/test_view.py index ae6580d..e8c2186 100644 --- a/tests/test_view.py +++ b/tests/test_view.py @@ -121,13 +121,17 @@ def test_savefig_1(evt, ext): assert np.sum(a1[:size] != a2[:size]) < 150 -def test_savefig_2(evt): +def test_savefig_2a(evt): with pytest.raises(ValueError): view.savefig(evt, "foo") + +def test_savefig_2b(evt): with pytest.raises(ValueError): view.savefig(evt, "foo.foo") + +def test_savefig_2c(evt): with pytest.raises(ValueError): with io.BytesIO() as f: view.savefig(evt, f)