Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

Merge remote-tracking branch 'upstream/2.6'

Adrián Chaves00ccb02f1fcc
diff --cc tests/test_engine.py
index 1bd802bcf,b8fd341f6..5677052f6
--- a/tests/test_engine.py
+++ b/tests/test_engine.py
@@@ -12,12 -12,13 +12,14 @@@ module with the ``runserver`` argument:
import os
import re
+ import subprocess
import sys
-import warnings
from collections import defaultdict
+ from threading import Timer
from urllib.parse import urlparse
+from dataclasses import dataclass
+import pytest
import attr
from itemadapter import ItemAdapter
from pydispatch import dispatcher
@@@ -483,7 -501,40 +485,38 @@@ class EngineTest(unittest.TestCase)
e.start()
yield e.close()
self.assertTrue(e.has_capacity())
- self.assertEqual(warning_list[0].category, ScrapyDeprecationWarning)
- self.assertEqual(str(warning_list[0].message), "ExecutionEngine.has_capacity is deprecated")
+ def test_short_timeout(self):
+ args = (
+ sys.executable,
+ '-m',
+ 'scrapy.cmdline',
+ 'fetch',
+ '-s',
+ 'CLOSESPIDER_TIMEOUT=0.001',
+ '-s',
+ 'LOG_LEVEL=DEBUG',
+ 'http://toscrape.com',
+ )
+ p = subprocess.Popen(
+ args,
+ stderr=subprocess.PIPE,
+ )
+
+ def kill_proc():
+ p.kill()
+ p.communicate()
+ assert False, 'Command took too much time to complete'
+
+ timer = Timer(15, kill_proc)
+ try:
+ timer.start()
+ _, stderr = p.communicate()
+ finally:
+ timer.cancel()
+
+ self.assertNotIn(b'Traceback', stderr)
+
if __name__ == "__main__":
if len(sys.argv) > 1 and sys.argv[1] == 'runserver':