-
Notifications
You must be signed in to change notification settings - Fork 300
Refactor assertGivesWarning into separate methods #2863
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
Conversation
pelson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy conceptually. The golden problem of naming remains... 😄
| # byte type. | ||
| cube = self._make_cube('>i1') | ||
| with self.assertGivesWarning(r'\(fill\|mask\)', expect_warning=False): | ||
| with self.assertDoesNotGiveWarning(r'\(fill\|mask\)'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename? assertNoWarningsMatching?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@djkirkham suggests: assertDoesNotGiveWarningRegexp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertDoesNotGiveWarningMatchingRegexp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertNoWarningsMatchingRegexp
lib/iris/tests/__init__.py
Outdated
| if expr.search(message)) | ||
|
|
||
| @contextlib.contextmanager | ||
| def assertGivesWarning(self, expected_regexp=''): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename? assertWarningsMatching?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@djkirkham suggests: assertGivesWarningRegexp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or even assertGivesWarningMatchingRegexp
|
On consideration, I don't like the original name. |
|
Some genuine test failures... |
d190be9 to
4f8b2d8
Compare
|
The failing test issue has been raised in #2875. |
It's confusing that
assertGivesWarningcan be used to assert that no warning is raised. I've refactored the code into separate methods.