# #
###############################################################################
-import os
import pakfire
import tests
self.assertEqual(key.algorithm, "Ed255919")
def _import(self, path):
- path = os.path.join(
- os.environ.get("TEST_DATA_DIR"), path,
- )
-
- with open(path, "rb") as f:
+ with self.open(path) as f:
payload = f.read()
return self.pakfire.import_key(payload)
#!/usr/bin/python3
-import os
-
import tests
class PackageTest(tests.TestCase):
self.pakfire = self.setup_pakfire()
def test_open(self):
- path = os.path.join(
- os.environ["TEST_DATA_DIR"],
- "beep-1.3-2.ip3.x86_64.pfm",
- )
+ path = self.path("beep-1.3-2.ip3.x86_64.pfm")
# Open the archive
a = self.pakfire.open(path)
import os
import unittest
+# Fetch TEST_DATA_DIR
+TEST_DATA_DIR = os.environ.get("TEST_DATA_DIR")
+if not TEST_DATA_DIR:
+ raise RuntimeError("TEST_DATA_DIR is not set")
+
class TestCase(unittest.TestCase):
"""
This is a TestCase class based on unittest.TestCase which has
return pakfire.Pakfire(ctx=ctx, path=path, **kwargs)
+ def path(self, *args, **kwargs):
+ """
+ Creates a path absolute to the test environment
+ """
+ return os.path.join(TEST_DATA_DIR, *args, **kwargs)
+
+ def open(self, path, *args, **kwargs):
+ """
+ Opens a file in the test environment
+ """
+ # Make the path absolute
+ path = self.path(path)
+
+ # Open the file
+ return open(path, *args, **kwargs)
+
# Overlay for now
main = unittest.main