diff options
author | Benjamin Schubert <contact@benschubert.me> | 2020-08-29 14:08:52 +0000 |
---|---|---|
committer | Benjamin Schubert <contact@benschubert.me> | 2020-10-06 19:06:10 +0000 |
commit | 7dfc468eb08b9af3f2aa4b78cd99b6ed64d660b6 (patch) | |
tree | f5c9c65ac2fe93ac16bef54d96ef39ea3ffb458f | |
parent | c314d8a501c2b50088e9ecbd1c954460bf56844b (diff) | |
download | buildstream-7dfc468eb08b9af3f2aa4b78cd99b6ed64d660b6.tar.gz |
downloadablefilesource.py: Reset the file opener between every test
This is required when we run this in the main process, with the threaded
scheduler rework.
Otherwise the state is kept between tests
-rw-r--r-- | src/buildstream/downloadablefilesource.py | 5 | ||||
-rw-r--r-- | src/buildstream/testing/_fixtures.py | 3 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/buildstream/downloadablefilesource.py b/src/buildstream/downloadablefilesource.py index 2c438b033..495b8bd4a 100644 --- a/src/buildstream/downloadablefilesource.py +++ b/src/buildstream/downloadablefilesource.py @@ -252,6 +252,11 @@ class DownloadableFileSource(Source): return self.__default_mirror_file + @classmethod + def _reset_url_opener(cls): + # Needed for tests, in order to cleanup the `netrc` configuration. + cls.__urlopener = None + def __get_urlopener(self): if not DownloadableFileSource.__urlopener: try: diff --git a/src/buildstream/testing/_fixtures.py b/src/buildstream/testing/_fixtures.py index 98778936d..520f68587 100644 --- a/src/buildstream/testing/_fixtures.py +++ b/src/buildstream/testing/_fixtures.py @@ -19,7 +19,7 @@ import psutil import pytest -from buildstream import node, utils +from buildstream import node, utils, DownloadableFileSource @pytest.fixture(autouse=True, scope="session") @@ -42,3 +42,4 @@ def thread_check(default_thread_number): @pytest.fixture(autouse=True) def reset_global_node_state(): node._reset_global_state() + DownloadableFileSource._reset_url_opener() |