Skip to content

Commit

Permalink
Fix type of exception in error handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
pavlis committed Feb 27, 2024
1 parent a36ff45 commit c4cc1b0
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions python/tests/algorithms/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import numpy as np

from mspasspy.ccore.seismic import (
TimeSeries,
Seismogram,
SlownessVector,
SeismogramEnsemble,
Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -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
Expand All @@ -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)


Expand Down Expand Up @@ -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)

0 comments on commit c4cc1b0

Please sign in to comment.