summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenjamin Schubert <bschubert15@bloomberg.net>2020-08-29 14:08:52 +0000
committerBenjamin Schubert <bschubert15@bloomberg.net>2020-12-01 10:58:01 +0000
commit0360bc1feca1d5429cdb7fbc083727d242499733 (patch)
treea8f7e8e465584c8170264fed6030d0812a722bcc /src
parent11b2aa717718b315d005ab5b29b56ec521424528 (diff)
downloadbuildstream-0360bc1feca1d5429cdb7fbc083727d242499733.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
Diffstat (limited to 'src')
-rw-r--r--src/buildstream/downloadablefilesource.py5
-rw-r--r--src/buildstream/testing/_fixtures.py3
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()