forked from spinalcordtoolbox/spinalcordtoolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconftest.py
30 lines (25 loc) · 1.17 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#############################################################################
#
# Configure tests so that pytest downloads testing data every time
# pytest is run from the sct directory
#
# ----------------------------------------------------------------------------
# Copyright (c) 2020 Polytechnique Montreal <www.neuro.polymtl.ca>
# Author: Julien Cohen-Adad, Chris Hammill
#
# About the license: see the file LICENSE.TXT
###############################################################################
import sys
from spinalcordtoolbox.utils import sct_dir_local_path, sct_test_path
sys.path.append(sct_dir_local_path('scripts'))
import pytest
import sct_download_data as downloader
@pytest.fixture(scope='session', autouse=True)
def download_data(request):
# This is a hack because the capsys fixture can't be used with
# session scope at the moment.
# https://github.com/pytest-dev/pytest/issues/2704#issuecomment-603387680
capmanager = request.config.pluginmanager.getplugin("capturemanager")
with capmanager.global_and_fixture_disabled():
print('\nDownloading sct testing data.')
downloader.main(['-d', 'sct_testing_data', '-o', sct_test_path()])