mirror of https://github.com/scrapy/scrapy.git
[test_downloadermiddleware_httpcache] Making xfails more informative
https://github.com/scrapy/scrapy/issues/4085
This commit is contained in:
parent
b3df0a8415
commit
70b2854590
|
|
@ -6,6 +6,7 @@ import unittest
|
|||
import email.utils
|
||||
from contextlib import contextmanager
|
||||
import pytest
|
||||
import sys
|
||||
|
||||
from scrapy.http import Response, HtmlResponse, Request
|
||||
from scrapy.spiders import Spider
|
||||
|
|
@ -89,7 +90,7 @@ class _BaseTest(unittest.TestCase):
|
|||
assert any(h in request2.headers for h in (b'If-None-Match', b'If-Modified-Since'))
|
||||
self.assertEqual(request1.body, request2.body)
|
||||
|
||||
@pytest.mark.xfail(reason='leveldb not supported in python 3.8')
|
||||
@pytest.mark.xfail(sys.version_info >= (3, 8), raises=RuntimeError, reason='leveldb not supported in python 3.8')
|
||||
def test_dont_cache(self):
|
||||
with self._middleware() as mw:
|
||||
self.request.meta['dont_cache'] = True
|
||||
|
|
@ -105,7 +106,7 @@ class _BaseTest(unittest.TestCase):
|
|||
|
||||
class DefaultStorageTest(_BaseTest):
|
||||
|
||||
@pytest.mark.xfail(reason='leveldb not supported in python 3.8')
|
||||
@pytest.mark.xfail(sys.version_info >= (3, 8), raises=RuntimeError, reason='leveldb not supported in python 3.8')
|
||||
def test_storage(self):
|
||||
with self._storage() as storage:
|
||||
request2 = self.request.copy()
|
||||
|
|
@ -119,7 +120,7 @@ class DefaultStorageTest(_BaseTest):
|
|||
time.sleep(2) # wait for cache to expire
|
||||
assert storage.retrieve_response(self.spider, request2) is None
|
||||
|
||||
@pytest.mark.xfail(reason='leveldb not supported in python 3.8')
|
||||
@pytest.mark.xfail(sys.version_info >= (3, 8), raises=RuntimeError, reason='leveldb not supported in python 3.8')
|
||||
def test_storage_never_expire(self):
|
||||
with self._storage(HTTPCACHE_EXPIRATION_SECS=0) as storage:
|
||||
assert storage.retrieve_response(self.spider, self.request) is None
|
||||
|
|
|
|||
Loading…
Reference in New Issue