From cc3eda36d8d91cf0f935c16387c084e6b6a46cee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gra=C3=B1a?= Date: Fri, 7 Feb 2014 01:36:43 -0200 Subject: [PATCH] test inspect.stack failure --- scrapy/tests/test_utils_deprecate.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scrapy/tests/test_utils_deprecate.py b/scrapy/tests/test_utils_deprecate.py index fd6bc90c3..2a042ba85 100644 --- a/scrapy/tests/test_utils_deprecate.py +++ b/scrapy/tests/test_utils_deprecate.py @@ -3,14 +3,18 @@ from __future__ import absolute_import import inspect import unittest import warnings +import mock from scrapy.utils.deprecate import create_deprecated_class + class MyWarning(UserWarning): pass + class SomeBaseClass(object): pass + class NewName(SomeBaseClass): pass @@ -234,3 +238,12 @@ class WarnWhenSubclassedTest(unittest.TestCase): self.assertIn('foo.Bar', str(w[0].message)) self.assertIn('AlsoDeprecated', str(w[1].message)) self.assertIn('foo.Bar', str(w[1].message)) + + def test_inspect_stack(self): + with mock.patch('inspect.stack', side_effect=IndexError): + with warnings.catch_warnings(record=True) as w: + DeprecatedName = create_deprecated_class('DeprecatedName', NewName) + class SubClass(DeprecatedName): + pass + + self.assertIn("Error detecting parent module", str(w[0].message))