diff --git a/swh/loader/package/tests/conftest.py b/swh/loader/package/tests/conftest.py index 5ad9771..7337816 100644 --- a/swh/loader/package/tests/conftest.py +++ b/swh/loader/package/tests/conftest.py @@ -1,14 +1,24 @@ # Copyright (C) 2019 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information +import os import pytest -from os import path @pytest.fixture def swh_config(monkeypatch, datadir): - conffile = path.join(datadir, 'loader.yml') + conffile = os.path.join(datadir, 'loader.yml') monkeypatch.setenv('SWH_CONFIG_FILENAME', conffile) return conffile + + +@pytest.fixture(autouse=True, scope='session') +def swh_proxy(): + """Automatically inject this fixture in all tests to ensure no outside + connection takes place. + + """ + os.environ['http_proxy'] = 'http://localhost:999' + os.environ['https_proxy'] = 'http://localhost:999' diff --git a/swh/loader/package/tests/conftest.py b/swh/loader/package/tests/test_conftest.py similarity index 57% copy from swh/loader/package/tests/conftest.py copy to swh/loader/package/tests/test_conftest.py index 5ad9771..d9d16e0 100644 --- a/swh/loader/package/tests/conftest.py +++ b/swh/loader/package/tests/test_conftest.py @@ -1,14 +1,12 @@ # Copyright (C) 2019 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information import pytest -from os import path +import requests -@pytest.fixture -def swh_config(monkeypatch, datadir): - conffile = path.join(datadir, 'loader.yml') - monkeypatch.setenv('SWH_CONFIG_FILENAME', conffile) - return conffile +def test_swh_proxy(): + with pytest.raises(requests.exceptions.ProxyError): + requests.get('https://www.softwareheritage.org')