1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Silenced warnings in deprecation tests.

This commit is contained in:
Jon Dufresne 2018-07-11 06:10:31 -07:00 committed by Tim Graham
parent e4c0878b30
commit e26b780a24

View File

@ -51,9 +51,11 @@ class RenameMethodsTests(SimpleTestCase):
"""
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:
@ -74,9 +76,11 @@ class RenameMethodsTests(SimpleTestCase):
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()
@ -93,9 +97,11 @@ class RenameMethodsTests(SimpleTestCase):
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):
@ -130,8 +136,10 @@ class RenameMethodsTests(SimpleTestCase):
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()