[test_downloadermiddleware_httpcache] Using skipif approach

https://github.com/scrapy/scrapy/issues/4085
This commit is contained in:
Roy 2019-10-28 11:24:09 +00:00
parent 3af2abb75b
commit 16bb3ac20d
1 changed files with 4 additions and 5 deletions

View File

@ -90,7 +90,6 @@ 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(sys.version_info >= (3, 8), raises=SystemError, reason='leveldb not supported in python 3.8')
def test_dont_cache(self):
with self._middleware() as mw:
self.request.meta['dont_cache'] = True
@ -106,7 +105,6 @@ class _BaseTest(unittest.TestCase):
class DefaultStorageTest(_BaseTest):
@pytest.mark.xfail(sys.version_info >= (3, 8), raises=SystemError, reason='leveldb not supported in python 3.8')
def test_storage(self):
with self._storage() as storage:
request2 = self.request.copy()
@ -120,7 +118,6 @@ class DefaultStorageTest(_BaseTest):
time.sleep(2) # wait for cache to expire
assert storage.retrieve_response(self.spider, request2) is None
@pytest.mark.xfail(sys.version_info >= (3, 8), raises=SystemError, 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
@ -164,8 +161,10 @@ class LeveldbStorageTest(DefaultStorageTest):
pytest.importorskip('leveldb')
except SystemError:
# Happens in python 3.8
# This will cause xfail in DefaultStorageTest to trigger
pass
pytest.mark.skipif(
sys.version_info >= (3, 8),
reason='leveldb not supported in python 3.8',
)
storage_class = 'scrapy.extensions.httpcache.LeveldbCacheStorage'