Skip to content

Commit 59fe99c

Browse files
chekunkovvshlapakov
authored andcommitted
fix test failure when test collection doesn't exist before test session starts
1 parent fc28d8a commit 59fe99c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

tests/hubstorage/conftest.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import pickle
55

66
import vcr
7-
import mock
87
import pytest
98
import shutil
109
import requests
10+
from requests import HTTPError
1111

1212
from scrapinghub import HubstorageClient
1313
from scrapinghub.hubstorage.utils import urlpathjoin
@@ -166,8 +166,13 @@ def get_test_collection(project):
166166

167167

168168
def clean_collection(collection):
169-
for item in collection.iter_values():
170-
collection.delete(item['_key'])
169+
try:
170+
for item in collection.iter_values():
171+
collection.delete(item['_key'])
172+
except HTTPError as e:
173+
# if collection doesn't exist yet service responds 404
174+
if e.response.status_code != 404:
175+
raise
171176

172177

173178
# Botgroups helpers section

0 commit comments

Comments
 (0)