Fix pollution of recent cache from tests

This commit is contained in:
Veronica Berglyd Olsen
2022-11-09 23:10:30 +01:00
parent eac7d9b9ee
commit e2f3a44d96
2 changed files with 7 additions and 7 deletions
+5 -5
View File
@@ -91,7 +91,7 @@ class Config:
# User Settings # User Settings
# ============= # =============
self._recentProj = RecentProjects(self._dataPath) self._recentProj = RecentProjects(self)
# General GUI Settings # General GUI Settings
self.guiLang = self._qLocal.name() self.guiLang = self._qLocal.name()
@@ -839,8 +839,8 @@ class Config:
class RecentProjects: class RecentProjects:
def __init__(self, dataPath): def __init__(self, mainConf):
self._dataPath = dataPath self.mainConf = mainConf
self._data = {} self._data = {}
return return
@@ -849,7 +849,7 @@ class RecentProjects:
""" """
self._data = {} self._data = {}
cacheFile = self._dataPath / nwFiles.RECENT_FILE cacheFile = self.mainConf.dataPath(nwFiles.RECENT_FILE)
if not cacheFile.is_file(): if not cacheFile.is_file():
return True return True
@@ -872,7 +872,7 @@ class RecentProjects:
def saveCache(self): def saveCache(self):
"""Save the cache dictionary of recent projects. """Save the cache dictionary of recent projects.
""" """
cacheFile = self._dataPath / nwFiles.RECENT_FILE cacheFile = self.mainConf.dataPath(nwFiles.RECENT_FILE)
cacheTemp = cacheFile.with_suffix(".tmp") cacheTemp = cacheFile.with_suffix(".tmp")
try: try:
with open(cacheTemp, mode="w+", encoding="utf-8") as outFile: with open(cacheTemp, mode="w+", encoding="utf-8") as outFile:
+2 -2
View File
@@ -411,11 +411,11 @@ def testBaseConfig_Internal(monkeypatch, tmpConf):
@pytest.mark.base @pytest.mark.base
def testBaseConfig_RecentCache(monkeypatch, fncPath): def testBaseConfig_RecentCache(monkeypatch, fncConf, fncPath):
"""Test recent cache file. """Test recent cache file.
""" """
cacheFile = fncPath / nwFiles.RECENT_FILE cacheFile = fncPath / nwFiles.RECENT_FILE
recent = RecentProjects(fncPath) recent = RecentProjects(fncConf)
# Load when there is no file should pass, but load nothing # Load when there is no file should pass, but load nothing
assert not cacheFile.exists() assert not cacheFile.exists()