Commit 392a993b authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

tests: correctly cleanup HOME environment variable

parent da036539
Pipeline #20309 failed with stage
...@@ -490,6 +490,7 @@ class TestCollectSnapshot(unittest.TestCase): ...@@ -490,6 +490,7 @@ class TestCollectSnapshot(unittest.TestCase):
self.slap = slapos.slap.slap() self.slap = slapos.slap.slap()
self.app = SlapOSApp() self.app = SlapOSApp()
self.temp_dir = tempfile.mkdtemp() self.temp_dir = tempfile.mkdtemp()
self.addCleanup(os.environ.__setitem__, "HOME", os.environ["HOME"])
os.environ["HOME"] = self.temp_dir os.environ["HOME"] = self.temp_dir
self.instance_root = tempfile.mkdtemp() self.instance_root = tempfile.mkdtemp()
self.software_root = tempfile.mkdtemp() self.software_root = tempfile.mkdtemp()
...@@ -638,6 +639,7 @@ class TestCollectEntity(unittest.TestCase): ...@@ -638,6 +639,7 @@ class TestCollectEntity(unittest.TestCase):
def setUp(self): def setUp(self):
self.temp_dir = tempfile.mkdtemp() self.temp_dir = tempfile.mkdtemp()
self.addCleanup(os.environ.__setitem__, "HOME", os.environ["HOME"])
os.environ["HOME"] = self.temp_dir os.environ["HOME"] = self.temp_dir
self.instance_root = tempfile.mkdtemp() self.instance_root = tempfile.mkdtemp()
self.software_root = tempfile.mkdtemp() self.software_root = tempfile.mkdtemp()
...@@ -850,6 +852,7 @@ class TestConsumptionReportBase(unittest.TestCase): ...@@ -850,6 +852,7 @@ class TestConsumptionReportBase(unittest.TestCase):
self.loadPredefinedDB() self.loadPredefinedDB()
self.database = db.Database(self.instance_root, create=True) self.database = db.Database(self.instance_root, create=True)
self.temp_dir = tempfile.mkdtemp() self.temp_dir = tempfile.mkdtemp()
self.addCleanup(os.environ.__setitem__, "HOME", os.environ["HOME"])
os.environ["HOME"] = self.temp_dir os.environ["HOME"] = self.temp_dir
self.software_root = tempfile.mkdtemp() self.software_root = tempfile.mkdtemp()
......
...@@ -46,6 +46,7 @@ class TestConfigureLocal(unittest.TestCase): ...@@ -46,6 +46,7 @@ class TestConfigureLocal(unittest.TestCase):
self.slap = slapos.slap.slap() self.slap = slapos.slap.slap()
self.app = SlapOSApp() self.app = SlapOSApp()
self.temp_dir = tempfile.mkdtemp() self.temp_dir = tempfile.mkdtemp()
self.addCleanup(os.environ.__setitem__, "HOME", os.environ["HOME"])
os.environ["HOME"] = self.temp_dir os.environ["HOME"] = self.temp_dir
self.instance_root = tempfile.mkdtemp() self.instance_root = tempfile.mkdtemp()
self.software_root = tempfile.mkdtemp() self.software_root = tempfile.mkdtemp()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment