Skip to content

Commit

Permalink
Update expected class method deprecation msgs in tests for py3.9
Browse files Browse the repository at this point in the history
Python 3.9 has fixed @classmethod combining with other decorators,
making deprecated correctly report 'class method' (instead of function
or static method).  Update the tests to account for that.

Fixes laurent-laporte-pro#29
  • Loading branch information
mgorny authored and tantale committed May 30, 2020
1 parent cdde25a commit efb3e60
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion tests/test_deprecated.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
import sys
import warnings

import pytest
Expand Down Expand Up @@ -184,7 +185,10 @@ def test_classic_deprecated_class_method__warns(classic_deprecated_class_method)
assert len(warns) == 1
warn = warns[0]
assert issubclass(warn.category, DeprecationWarning)
assert "deprecated function (or staticmethod)" in str(warn.message)
if sys.version_info >= (3, 9):
assert "deprecated class method" in str(warn.message)
else:
assert "deprecated function (or staticmethod)" in str(warn.message)
assert warn.filename == __file__, 'Incorrect warning stackLevel'


Expand Down
5 changes: 4 additions & 1 deletion tests/test_sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,10 @@ def test_sphinx_deprecated_class_method__warns(sphinx_deprecated_class_method):
assert len(warns) == 1
warn = warns[0]
assert issubclass(warn.category, DeprecationWarning)
assert "deprecated function (or staticmethod)" in str(warn.message)
if sys.version_info >= (3, 9):
assert "deprecated class method" in str(warn.message)
else:
assert "deprecated function (or staticmethod)" in str(warn.message)


def test_should_raise_type_error():
Expand Down

0 comments on commit efb3e60

Please sign in to comment.