Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions news/squeeze_tests.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* No news: fixing tests, no user-facing changes.

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
38 changes: 26 additions & 12 deletions tests/test_morphsqueeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,16 @@ def test_morphsqueeze_extrapolate(user_filesystem, squeeze_coeffs, wmsg_gen):
squeeze=coeffs,
apply=True,
)
assert len(warning) == 1
assert warning[0].category is UserWarning
actual_wmsg = str(warning[0].message)
expected_wmsg = wmsg_gen([min(x_squeezed), max(x_squeezed)])
assert actual_wmsg == expected_wmsg
assert len(warning) >= 1
expected_wmsg = wmsg_gen([min(x_squeezed), max(x_squeezed)])
message_found = False
for w in warning:
actual_wmsg = str(w.message)
if actual_wmsg == expected_wmsg:
if w.category is UserWarning:
message_found = True
break
assert message_found

# CLI test
morph_file, target_file = create_morph_data_file(
Expand Down Expand Up @@ -272,9 +277,7 @@ def test_squeeze_warnings(user_filesystem, squeeze_coeffs, x_morph):
squeeze=squeeze_coeffs,
apply=True,
)
assert len(warning) == 1
assert warning[0].category is UserWarning
actual_wmsg = str(warning[0].message)
assert len(warning) >= 1
expected_wmsg = (
"Warning: The squeeze morph has interpolated your morphed "
"function from a non-monotonically increasing grid. "
Expand All @@ -295,7 +298,14 @@ def test_squeeze_warnings(user_filesystem, squeeze_coeffs, x_morph):
"first apply a --hshift and --stretch morph. "
"Then, use the hshift parameter for a0 and stretch parameter for a1."
)
assert expected_wmsg in actual_wmsg
message_found = False
for w in warning:
actual_wmsg = str(w.message)
if expected_wmsg in actual_wmsg:
if w.category is UserWarning:
message_found = True
break
assert message_found

# call in CLI
morph_file, target_file = create_morph_data_file(
Expand All @@ -314,9 +324,13 @@ def test_squeeze_warnings(user_filesystem, squeeze_coeffs, x_morph):
)
with pytest.warns(UserWarning) as warning:
single_morph(parser, opts, pargs, stdout_flag=False)
assert len(warning) == 1
actual_wmsg = str(warning[0].message)
assert expected_wmsg in actual_wmsg
assert len(warning) >= 1
message_found = False
for w in warning:
actual_wmsg = str(w.message)
if expected_wmsg in actual_wmsg:
message_found = True
assert message_found


@pytest.mark.parametrize(
Expand Down
Loading