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