Skip to content

Refactor assertGivesWarning into separate methods#2863

Merged
pelson merged 2 commits into
SciTools:masterfrom
djkirkham:assertDoesNotGiveWarning
Oct 27, 2017
Merged

Refactor assertGivesWarning into separate methods#2863
pelson merged 2 commits into
SciTools:masterfrom
djkirkham:assertDoesNotGiveWarning

Conversation

@djkirkham

Copy link
Copy Markdown
Contributor

It's confusing that assertGivesWarning can be used to assert that no warning is raised. I've refactored the code into separate methods.

@djkirkham djkirkham requested a review from pp-mo October 26, 2017 09:28

@pelson pelson left a comment

Copy link
Copy Markdown
Member

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\)'):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

rename? assertNoWarningsMatching?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@djkirkham suggests: assertDoesNotGiveWarningRegexp

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

assertDoesNotGiveWarningMatchingRegexp

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

assertNoWarningsMatchingRegexp

Comment thread lib/iris/tests/__init__.py Outdated
if expr.search(message))

@contextlib.contextmanager
def assertGivesWarning(self, expected_regexp=''):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

rename? assertWarningsMatching?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@djkirkham suggests: assertGivesWarningRegexp

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Or even assertGivesWarningMatchingRegexp

@pp-mo

pp-mo commented Oct 26, 2017

Copy link
Copy Markdown
Member

On consideration, I don't like the original name.
But it shouldn't need to be as unwieldy as some of the recent suggestions.
Anyone for "AssertWarnsRegexp" and "AssertNoWarningsRegexp" ?

@pelson

pelson commented Oct 26, 2017

Copy link
Copy Markdown
Member

Some genuine test failures...

@djkirkham djkirkham force-pushed the assertDoesNotGiveWarning branch from d190be9 to 4f8b2d8 Compare October 26, 2017 16:11
@pelson

pelson commented Oct 27, 2017

Copy link
Copy Markdown
Member

The failing test issue has been raised in #2875.

@pelson pelson merged commit c93132b into SciTools:master Oct 27, 2017
@QuLogic QuLogic added this to the v2.0.0 milestone Oct 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants