Skip to content
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

Added asserts for all warnings in deprecation tests. #10172

Merged
merged 1 commit into from Jul 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 19 additions & 11 deletions tests/deprecation/tests.py
Expand Up @@ -51,9 +51,11 @@ def test_get_old_defined(self):
"""
Ensure `old` complains when only `old` is defined.
"""
class Manager(metaclass=RenameManagerMethods):
def old(self):
pass
msg = '`Manager.old` method should be renamed `new`.'
with self.assertWarnsMessage(DeprecationWarning, msg):
class Manager(metaclass=RenameManagerMethods):
def old(self):
pass
manager = Manager()

with warnings.catch_warnings(record=True) as recorded:
Expand All @@ -74,9 +76,11 @@ class Renamed(metaclass=RenameManagerMethods):
def new(self):
pass

class Deprecated(Renamed):
def old(self):
super().old()
msg = '`Deprecated.old` method should be renamed `new`.'
with self.assertWarnsMessage(DeprecationWarning, msg):
class Deprecated(Renamed):
def old(self):
super().old()

deprecated = Deprecated()

Expand All @@ -93,9 +97,11 @@ def test_renamed_subclass_deprecated(self):
Ensure the correct warnings are raised when a class that renamed
`old` subclass one that didn't.
"""
class Deprecated(metaclass=RenameManagerMethods):
def old(self):
pass
msg = '`Deprecated.old` method should be renamed `new`.'
with self.assertWarnsMessage(DeprecationWarning, msg):
class Deprecated(metaclass=RenameManagerMethods):
def old(self):
pass

class Renamed(Deprecated):
def new(self):
Expand Down Expand Up @@ -130,8 +136,10 @@ class DeprecatedMixin:
def old(self):
super().old()

class Deprecated(DeprecatedMixin, RenamedMixin, Renamed):
pass
msg = '`DeprecatedMixin.old` method should be renamed `new`.'
with self.assertWarnsMessage(DeprecationWarning, msg):
class Deprecated(DeprecatedMixin, RenamedMixin, Renamed):
pass

deprecated = Deprecated()

Expand Down