From 2be05300479325e5a0c7ec9bd4b5c42fee66ab39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Budai?= Date: Mon, 7 Oct 2019 10:00:37 +0200 Subject: [PATCH] tests: Use one store per class instead of per test method For stages testing it is too slow to rebuild the a image containing @Core packages every time. Let's just reuse the a image for all tests. This should speed up the test running time a LOT. --- test/osbuildtest.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/test/osbuildtest.py b/test/osbuildtest.py index 8a149ea9..2487fb47 100644 --- a/test/osbuildtest.py +++ b/test/osbuildtest.py @@ -13,21 +13,24 @@ class TestCase(unittest.TestCase): """A TestCase to test running the osbuild program. Each test case can use `self.run_osbuild()` to run osbuild. A temporary - store is used, which can be accessed through `self.store`. + store is used, which can be accessed through `self.store`. The store is + persistent for whole test class due to performance concerns. To speed up local development, OSBUILD_TEST_STORE can be set to an existing store. Note that this might make tests dependant of each other. Do not use it for actual testing. """ - def setUp(self): - self.store = os.getenv("OSBUILD_TEST_STORE") - if not self.store: - self.store = tempfile.mkdtemp(dir="/var/tmp") + @classmethod + def setUpClass(cls): + cls.store = os.getenv("OSBUILD_TEST_STORE") + if not cls.store: + cls.store = tempfile.mkdtemp(dir="/var/tmp") - def tearDown(self): + @classmethod + def tearDownClass(cls): if not os.getenv("OSBUILD_TEST_STORE"): - shutil.rmtree(self.store) + shutil.rmtree(cls.store) def run_osbuild(self, pipeline, input=None): osbuild_cmd = ["python3", "-m", "osbuild", "--json", "--store", self.store, "--libdir", ".", pipeline]