import os
import pakfire
-import unittest
-class KeysTests(unittest.TestCase):
+import tests
+
+class KeysTests(tests.TestCase):
"""
This tests the keys
"""
def setUp(self):
- path = os.environ.get("TEST_STUB_ROOT")
- if not path:
- raise RuntimeError("TEST_STUB_ROOT is not defined")
-
- self.pakfire = pakfire.Pakfire(path)
+ self.pakfire = self.setup_pakfire()
def test_generate(self):
"""
if __name__ == "__main__":
- unittest.main()
+ tests.main()
--- /dev/null
+###############################################################################
+# #
+# Pakfire - The IPFire package management system #
+# Copyright (C) 2024 Pakfire development team #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+# #
+###############################################################################
+
+import pakfire
+import os
+import unittest
+
+class TestCase(unittest.TestCase):
+ """
+ This is a TestCase class based on unittest.TestCase which has
+ a couple of handy methods that we frequently need.
+ """
+ def setup_ctx(self, path=None, **kwargs):
+ """
+ Sets up a new Pakfire context
+ """
+ if path is None:
+ path = os.environ.get("TEST_CONFIG_FILE")
+
+ # Return a new context
+ return pakfire.Ctx(path=path, **kwargs)
+
+ def setup_pakfire(self, ctx=None, path=None, **kwargs):
+ """
+ Sets up a new Pakfire environment
+ """
+ # Create a context if none given
+ if ctx is None:
+ ctx = self.setup_ctx()
+
+ if path is None:
+ path = os.environ.get("TEST_STUB_ROOT")
+
+ return pakfire.Pakfire(ctx=ctx, path=path, **kwargs)
+
+
+# Overlay for now
+main = unittest.main