Skip to content

Commit 142ac95

Browse files
authored
Merge pull request #55 from scrapinghub/fix-travis-errors
Handle deprecations related with scrapy v1.6
2 parents e5a1eb9 + 687a7ed commit 142ac95

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

sh_scrapy/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
"scrapy_querycleaner.QueryCleanerMiddleware",
2323
"scrapylib.splitvariants.SplitVariantsMiddleware":
2424
"scrapy_splitvariants.SplitVariantsMiddleware",
25+
"scrapy.contrib.throttle.AutoThrottle":
26+
"scrapy.extensions.throttle.AutoThrottle",
2527
}
2628
SLYBOT_SPIDER_MANAGER = 'slybot.spidermanager.ZipfileSlybotSpiderManager'
2729
SLYBOT_DUPE_FILTER = 'slybot.dupefilter.DupeFilterPipeline'

tests/test_settings.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -315,14 +315,13 @@ def test_populate_settings_keep_user_priorities(get_settings_mock):
315315
'scrapy.contrib.throttle.AutoThrottle': 5}},
316316
'enabled_addons': [addon]}
317317
result = _populate_settings_base(api_settings, lambda x: x, spider=True)
318-
assert result.getdict('EXTENSIONS_BASE')[
319-
'sh_scrapy.extension.HubstorageExtension'] is None
320-
assert result.getdict('EXTENSIONS_BASE').get(
321-
'scrapy.contrib.throttle.AutoThrottle') is None
322-
assert result.getdict('EXTENSIONS_BASE')[
323-
'scrapy.extensions.throttle.AutoThrottle'] == 5
324318
assert result.getdict('SPIDER_MIDDLEWARES_BASE')[
325319
'scrapy.utils.misc.load_object'] == 1
320+
assert result.getdict('EXTENSIONS_BASE')[
321+
'sh_scrapy.extension.HubstorageExtension'] is None
322+
autothrottles = [k for k in result.getdict('EXTENSIONS_BASE')
323+
if 'AutoThrottle' in k]
324+
assert result.getdict('EXTENSIONS_BASE')[autothrottles[0]] == 5
326325

327326

328327
def test_populate_settings_unique_update_dict():
@@ -343,8 +342,7 @@ def test_populate_settings_keep_user_priorities_oldpath(get_settings_mock):
343342
autothrottles = [k for k in result.getdict('EXTENSIONS_BASE')
344343
if 'AutoThrottle' in k]
345344
assert len(autothrottles) == 1
346-
assert result.getdict('EXTENSIONS_BASE')[
347-
'scrapy.extensions.throttle.AutoThrottle'] is 0
345+
assert result.getdict('EXTENSIONS_BASE')[autothrottles[0]] is 0
348346

349347

350348
def test_load_default_settings():
@@ -409,12 +407,12 @@ def test_update_old_classpaths_not_string():
409407
class CustomObject(object):
410408
pass
411409

412-
test_value = {'scrapy.contrib.exporter.CustomExporter': 1,
410+
test_value = {'scrapy.exporter.CustomExporter': 1,
413411
123: 2, CustomObject: 3}
414412
test_settings = Settings({'SOME_SETTING': test_value})
415413
_update_old_classpaths(test_settings)
416-
expected = test_settings['SOME_SETTING'].keys()
414+
expected = test_settings['SOME_SETTING']
417415
assert len(expected) == 3
418416
assert 123 in expected
419417
assert CustomObject in expected
420-
assert 'scrapy.exporters.CustomExporter' in expected
418+
assert 'scrapy.exporter.CustomExporter' in expected

0 commit comments

Comments
 (0)