Skip to content

Commit

Permalink
FIX: Version comparison on alert_future_error
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Jan 9, 2023
1 parent 4180847 commit 5f37ffa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nibabel/deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def alert_future_error(
Warnings stacklevel to provide; note that this will be incremented by
1, so provide the stacklevel you would provide directly to warnings.warn()
"""
if cmp_pkg_version(version) >= 0:
if cmp_pkg_version(version) > 0:
msg = f'{msg} This will error in NiBabel {version}. {warning_rec}'
warnings.warn(msg.strip(), warning_class, stacklevel=stacklevel + 1)
else:
Expand Down
8 changes: 8 additions & 0 deletions nibabel/tests/test_deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,11 @@ def test_alert_future_error():
error_rec='Fix this issue by doing XYZ.',
error_class=ValueError,
)
with pytest.raises(ValueError):
alert_future_error(
'Message',
'2.0.0', # Error if we equal the (patched) version
warning_rec='Silence this warning by doing XYZ.',
error_rec='Fix this issue by doing XYZ.',
error_class=ValueError,
)

0 comments on commit 5f37ffa

Please sign in to comment.