mirror of https://github.com/scrapy/scrapy.git
Make update_classpath() util function return non-string objects
This commit is contained in:
parent
d18b6a61d7
commit
9f7fcf5582
|
|
@ -1,5 +1,6 @@
|
|||
"""Some helpers for deprecation messages"""
|
||||
|
||||
import six
|
||||
import warnings
|
||||
import inspect
|
||||
from scrapy.exceptions import ScrapyDeprecationWarning
|
||||
|
|
@ -149,6 +150,8 @@ DEPRECATION_RULES = [
|
|||
|
||||
def update_classpath(path):
|
||||
"""Update a deprecated path from an object with its new location"""
|
||||
if not isinstance(path, six.string_types):
|
||||
return path
|
||||
for prefix, replacement in DEPRECATION_RULES:
|
||||
if path.startswith(prefix):
|
||||
new_path = path.replace(prefix, replacement, 1)
|
||||
|
|
|
|||
|
|
@ -279,3 +279,7 @@ class UpdateClassPathTest(unittest.TestCase):
|
|||
output = update_classpath('scrapy.unmatched.Path')
|
||||
self.assertEqual(output, 'scrapy.unmatched.Path')
|
||||
self.assertEqual(len(w), 0)
|
||||
|
||||
def test_returns_nonstring(self):
|
||||
for notastring in [None, True, [1, 2, 3], object()]:
|
||||
self.assertEqual(update_classpath(notastring), notastring)
|
||||
|
|
|
|||
Loading…
Reference in New Issue