mirror of https://github.com/scrapy/scrapy.git
Improve test coverage
This commit is contained in:
parent
f9ba3033b3
commit
cf1bb71be0
|
|
@ -65,10 +65,11 @@ def create_deprecated_class(
|
|||
# deprecated_class() takes the module of the alias from its calling frame,
|
||||
# which is this function and the decorator wrapping it, so skip past both.
|
||||
frame = inspect.currentframe()
|
||||
while frame is not None and frame.f_globals.get("__name__") in _WRAPPER_MODULES:
|
||||
assert frame is not None
|
||||
while frame.f_globals.get("__name__") in _WRAPPER_MODULES:
|
||||
assert frame.f_back is not None
|
||||
frame = frame.f_back
|
||||
if frame is not None:
|
||||
cls.__module__ = frame.f_globals.get("__name__", cls.__module__)
|
||||
cls.__module__ = frame.f_globals.get("__name__", cls.__module__)
|
||||
return cls
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,13 +6,22 @@ from unittest import mock
|
|||
import pytest
|
||||
|
||||
from scrapy.exceptions import ScrapyDeprecationWarning
|
||||
from scrapy.utils.deprecate import create_deprecated_class, update_classpath
|
||||
from scrapy.utils.deprecate import attribute, create_deprecated_class, update_classpath
|
||||
|
||||
|
||||
class NewName:
|
||||
pass
|
||||
|
||||
|
||||
def test_attribute():
|
||||
with pytest.warns(
|
||||
ScrapyDeprecationWarning,
|
||||
match=r"NewName\.old attribute is deprecated and will be no longer supported"
|
||||
r" in Scrapy 1\.0, use NewName\.new attribute instead",
|
||||
):
|
||||
attribute(NewName(), "old", "new", version="1.0")
|
||||
|
||||
|
||||
class TestCreateDeprecatedClass:
|
||||
def test_warns_about_itself(self):
|
||||
with pytest.warns(
|
||||
|
|
|
|||
Loading…
Reference in New Issue