diff options
author | Jon Dufresne <jon.dufresne@gmail.com> | 2018-07-11 06:10:31 -0700 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2018-07-11 09:10:31 -0400 |
commit | e26b780a24302ea0589a2e77b634d280d324474e (patch) | |
tree | 4fd03eec7d333aede1d2594d7931fa897fa4da68 /tests/deprecation | |
parent | e4c0878b30cf1fc29212185c55614fc463393af1 (diff) | |
download | django-e26b780a24302ea0589a2e77b634d280d324474e.tar.gz |
Silenced warnings in deprecation tests.
Diffstat (limited to 'tests/deprecation')
-rw-r--r-- | tests/deprecation/tests.py | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/tests/deprecation/tests.py b/tests/deprecation/tests.py index b3ab78d1ca..0d2ea298d3 100644 --- a/tests/deprecation/tests.py +++ b/tests/deprecation/tests.py @@ -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() |