Skip to content

Simplify interface for testing of warnings. #345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 3, 2015
Merged

Simplify interface for testing of warnings. #345

merged 4 commits into from
Sep 3, 2015

Conversation

bcipolli
Copy link
Contributor

@bcipolli bcipolli commented Sep 2, 2015

This is a fix for #343

  • New interface: suppress_warnings, clear_and_catch_warnings, and error_warnings.
  • Deprecate ErrorWarnings, IgnoreWarnings, and catch_warn_reset; nibabel.checkwarns.

I haven't added tests for the deprecation, but I can do that. I am just feeling lazy 😅

else:
from nose.tools import (assert_equal, assert_not_equal,
assert_true, assert_false, assert_raises)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matthew-brett Any idea if try...catch is still necessary? I took the liberty to blow it away. I couldn't tell from the commits (5+ years ago) where this was being used. I didn't see nt being used anywhere in my cursory search, and tests pass...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so that people can still import nibabel if they don't have nose installed.

@bcipolli bcipolli changed the title Simplify interface for testing of warnings. WIP: Simplify interface for testing of warnings. Sep 2, 2015
@bcipolli bcipolli changed the title WIP: Simplify interface for testing of warnings. Simplify interface for testing of warnings. Sep 2, 2015
@matthew-brett
Copy link
Member

Oops - mixed in with the array class refactoring?

Ben Cipollini added 3 commits September 3, 2015 07:51
@bcipolli
Copy link
Contributor Author

bcipolli commented Sep 3, 2015

Everything's set, except one test failure (checking warnings from the checkwarns module import). Strangely, the tests succeed locally. Any ideas?


def test_ignore_and_error_warnings():
with clear_and_catch_warnings() as w:
from .. import checkwarns
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing what is happening here is that nose has previously imported checkwarns as part of test discovery for the while test-suite, and therefore there is no Future warning, because the import has already happened.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way - I do see the error if I run the full test-suite locally, but not if I run the individual test.

@bcipolli
Copy link
Contributor Author

bcipolli commented Sep 3, 2015

I changed the offending test to an ignore_warnings block, as I'm stumped and would rather use the time on more important things. Hope that's cool!

I looked over the coverage change, and I didn't see any obvious gaps (as well as I could from the reports available).

I believe this is ready to go, and to focus on #329 , then back to GIFTI / CIFTI (which is what this is all really about!)

@matthew-brett
Copy link
Member

Yes, that's fine, thanks for doing that.

matthew-brett added a commit that referenced this pull request Sep 3, 2015
MRG: Simplify interface for testing of warnings.

This is a fix for #343

New interface: suppress_warnings, clear_and_catch_warnings, and error_warnings.
Deprecate ErrorWarnings, IgnoreWarnings, and catch_warn_reset; nibabel.checkwarns.
@matthew-brett matthew-brett merged commit 7fe2ebc into nipy:master Sep 3, 2015
@bcipolli bcipolli deleted the refactor_warning_tests branch September 4, 2015 19:49
@bcipolli bcipolli restored the refactor_warning_tests branch September 16, 2015 13:26
@bcipolli bcipolli deleted the refactor_warning_tests branch September 16, 2015 13:48
grlee77 pushed a commit to grlee77/nibabel that referenced this pull request Mar 15, 2016
MRG: Simplify interface for testing of warnings.

This is a fix for nipy#343

New interface: suppress_warnings, clear_and_catch_warnings, and error_warnings.
Deprecate ErrorWarnings, IgnoreWarnings, and catch_warn_reset; nibabel.checkwarns.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants