mirror of
https://github.com/scrapy/scrapy.git
synced 2025-02-25 08:03:48 +00:00
silence irrelevant (and confusing) errors generated in tests by signals left active after engine tests run - we should really rewrite engine tests asap
This commit is contained in:
parent
bb2e0de7da
commit
a08e62a25d
@ -101,6 +101,14 @@ class CrawlingSession(object):
|
||||
scrapymanager.start()
|
||||
self.port.stopListening()
|
||||
self.wasrun = True
|
||||
# FIXME: extremly ugly hack to avoid propagating errors to other
|
||||
# stats because of living signals. This whole test_engine.py should
|
||||
# be rewritten from scratch actually.
|
||||
from scrapy.utils.signal import disconnect_all
|
||||
from scrapy.stats import signals as stats_signals
|
||||
disconnect_all(stats_signals.stats_spider_opened)
|
||||
disconnect_all(stats_signals.stats_spider_closing)
|
||||
disconnect_all(stats_signals.stats_spider_closed)
|
||||
|
||||
def geturl(self, path):
|
||||
return "http://localhost:%s%s" % (self.portno, path)
|
||||
|
@ -2,7 +2,8 @@
|
||||
|
||||
from twisted.python.failure import Failure
|
||||
|
||||
from scrapy.xlib.pydispatch.dispatcher import Any, Anonymous, liveReceivers, getAllReceivers
|
||||
from scrapy.xlib.pydispatch.dispatcher import Any, Anonymous, liveReceivers, \
|
||||
getAllReceivers, disconnect
|
||||
from scrapy.xlib.pydispatch.robustapply import robustApply
|
||||
|
||||
from scrapy import log
|
||||
@ -27,3 +28,10 @@ def send_catch_log(signal=Any, sender=Anonymous, *arguments, **named):
|
||||
result = response
|
||||
responses.append((receiver, result))
|
||||
return responses
|
||||
|
||||
def disconnect_all(signal=Any, sender=Any):
|
||||
"""Disconnect all signal handlers. Useful for cleaning up after running
|
||||
tests
|
||||
"""
|
||||
for receiver in liveReceivers(getAllReceivers(sender, signal)):
|
||||
disconnect(receiver, signal=signal, sender=sender)
|
||||
|
Loading…
x
Reference in New Issue
Block a user