From c4cc1b0d03ab3fc09a44bb3e19146861230a3477 Mon Sep 17 00:00:00 2001 From: Gary Pavlis Date: Mon, 26 Feb 2024 21:07:23 -0500 Subject: [PATCH] Fix type of exception in error handlers --- python/tests/algorithms/test_basic.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/python/tests/algorithms/test_basic.py b/python/tests/algorithms/test_basic.py index 10e5e6ee0..3da12bdc9 100644 --- a/python/tests/algorithms/test_basic.py +++ b/python/tests/algorithms/test_basic.py @@ -3,6 +3,7 @@ import numpy as np from mspasspy.ccore.seismic import ( + TimeSeries, Seismogram, SlownessVector, SeismogramEnsemble, @@ -356,8 +357,9 @@ def fstout_ok(s): assert sout.dead() assert sout.elog.size() == 1 # invalid arg0 should throw an exception - x = "foobar" - with pytest.raises(ValueError, match="received invalid type"): + x = TimeSeries() + x.set_live() + with pytest.raises(TypeError, match="received invalid type"): sout = free_surface_transformation(x) @@ -419,12 +421,12 @@ def test_transform_to_RTZ(): # atomic version tests what is needed for arg method and # is not recommended for ensembles anyway nmembers = 3 - e = SeismogramEnsemble(3) + e = SeismogramEnsemble(nmembers) az = 90.0 - phi seaz = az + 180.0 seis = Seismogram(seis0) seis["seaz"] = seaz - for i in range(3): + for i in range(nmembers): e.member.append(Seismogram(seis)) # ensemble is 3 copies of the same data this test used above # has seaz set @@ -451,8 +453,9 @@ def test_transform_to_RTZ(): assert sout.dead() # invalid data throws an exception - x = "foobar" - with pytest.raises(ValueError, match="received invalid type"): + x = TimeSeries() + x.set_live() + with pytest.raises(TypeError, match="received invalid type"): sout = transform_to_RTZ(x) @@ -596,6 +599,7 @@ def is_identity(s): assert sout.dead() # invalid data throws an exception - x = "foobar" - with pytest.raises(ValueError, match="received invalid type"): - sout = transform_to_RTZ(x) + x = TimeSeries() + x.set_live() + with pytest.raises(TypeError, match="received invalid type"): + sout = transform_to_LQT(x)