Skip to content

Commit bd57bf3

Browse files
committed
Ignore cassettes option, optimise cleaning
1 parent 993c79b commit bd57bf3

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

tests/hubstorage/conftest.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,12 @@ def pytest_configure(config):
6363
if os.path.exists(VCR_CASSETES_DIR):
6464
shutil.rmtree(VCR_CASSETES_DIR)
6565
elif config.option.ignore_cassettes:
66-
# TODO somehow skip cassettes
67-
pass
66+
# simple hack to just ignore vcr cassettes:
67+
# - all record_mode means recording new interactions + no replay
68+
# - before_record returning None means skipping all the requests
69+
global my_vcr
70+
my_vcr.record_mode = 'all'
71+
my_vcr.before_record_request = lambda request: None
6872

6973

7074
@pytest.fixture(scope='session')
@@ -112,8 +116,12 @@ def setup_vcrpy(request, hsproject):
112116
request.function.__module__.split('.')[-1],
113117
request.function.__name__
114118
)
115-
with my_vcr.use_cassette(cassette_name):
119+
# we should clean jobs only when working with real services
120+
# doesn't make sense to clean jobs when working with cassettes
121+
if (request.config.option.update_cassettes or
122+
request.config.option.ignore_cassettes):
116123
remove_all_jobs(hsproject)
124+
with my_vcr.use_cassette(cassette_name):
117125
yield
118126

119127

0 commit comments

Comments
 (0)