f724ee
From 3b9a781e138830a190d16c8dd970b800a086de46 Mon Sep 17 00:00:00 2001
f724ee
From: Vojtech Trefny <vtrefny@redhat.com>
f724ee
Date: Wed, 4 Aug 2021 13:00:53 +0200
f724ee
Subject: [PATCH 1/3] edd_test: Locate the edd_data based on the test file
f724ee
 location
f724ee
f724ee
We can't use the blivet.edd module location when running tests
f724ee
against installed version of blivet.
f724ee
---
f724ee
 tests/devicelibs_test/edd_test.py | 5 ++---
f724ee
 1 file changed, 2 insertions(+), 3 deletions(-)
f724ee
f724ee
diff --git a/tests/devicelibs_test/edd_test.py b/tests/devicelibs_test/edd_test.py
f724ee
index 23d736f4..7ec8d1e6 100644
f724ee
--- a/tests/devicelibs_test/edd_test.py
f724ee
+++ b/tests/devicelibs_test/edd_test.py
f724ee
@@ -1,7 +1,6 @@
f724ee
 import unittest
f724ee
 import mock
f724ee
 import os
f724ee
-import inspect
f724ee
 import logging
f724ee
 import copy
f724ee
 
f724ee
@@ -110,9 +109,9 @@ class EddTestCase(unittest.TestCase):
f724ee
                 name = name[:-1]
f724ee
             if name.startswith("/"):
f724ee
                 name = name[1:]
f724ee
-            dirname = os.path.dirname(inspect.getfile(edd))
f724ee
+            dirname = os.path.abspath(os.path.dirname(__file__))
f724ee
             return os.path.join(dirname,
f724ee
-                                "../../tests/devicelibs_test/edd_data/",
f724ee
+                                "edd_data/",
f724ee
                                 name)
f724ee
 
f724ee
     def edd_debug(self, *args):
f724ee
-- 
f724ee
2.31.1
f724ee
f724ee
f724ee
From 7ad3824fceb98e2741820b76a9cfea5add338343 Mon Sep 17 00:00:00 2001
f724ee
From: Vojtech Trefny <vtrefny@redhat.com>
f724ee
Date: Wed, 4 Aug 2021 13:02:08 +0200
f724ee
Subject: [PATCH 2/3] tests: Allow running tests without the tests directory in
f724ee
 PYTHONPATH
f724ee
f724ee
When running the tests against installed version of blivet, the
f724ee
"tests" directory is not in PYTHONPATH so we need to import all
f724ee
helper modules using relative path.
f724ee
---
f724ee
 tests/action_test.py                           | 2 +-
f724ee
 tests/devicelibs_test/edd_test.py              | 2 +-
f724ee
 tests/{ => devicelibs_test}/lib.py             | 0
f724ee
 tests/formats_test/fs_test.py                  | 2 +-
f724ee
 tests/formats_test/fslabeling.py               | 2 +-
f724ee
 tests/formats_test/fstesting.py                | 2 +-
f724ee
 tests/formats_test/fsuuid.py                   | 2 +-
f724ee
 tests/formats_test/labeling_test.py            | 2 +-
f724ee
 tests/{ => formats_test}/loopbackedtestcase.py | 0
f724ee
 tests/formats_test/luks_test.py                | 2 +-
f724ee
 tests/formats_test/lvmpv_test.py               | 2 +-
f724ee
 tests/partitioning_test.py                     | 2 +-
f724ee
 12 files changed, 10 insertions(+), 10 deletions(-)
f724ee
 rename tests/{ => devicelibs_test}/lib.py (100%)
f724ee
 rename tests/{ => formats_test}/loopbackedtestcase.py (100%)
f724ee
f724ee
diff --git a/tests/action_test.py b/tests/action_test.py
f724ee
index 38a2e872..1e84c20b 100644
f724ee
--- a/tests/action_test.py
f724ee
+++ b/tests/action_test.py
f724ee
@@ -6,7 +6,7 @@ if PY3:
f724ee
 else:
f724ee
     from mock import Mock
f724ee
 
f724ee
-from tests.storagetestcase import StorageTestCase
f724ee
+from storagetestcase import StorageTestCase
f724ee
 import blivet
f724ee
 from blivet.formats import get_format
f724ee
 from blivet.size import Size
f724ee
diff --git a/tests/devicelibs_test/edd_test.py b/tests/devicelibs_test/edd_test.py
f724ee
index 7ec8d1e6..379c7aeb 100644
f724ee
--- a/tests/devicelibs_test/edd_test.py
f724ee
+++ b/tests/devicelibs_test/edd_test.py
f724ee
@@ -6,7 +6,7 @@ import copy
f724ee
 
f724ee
 from blivet import arch
f724ee
 from blivet.devicelibs import edd
f724ee
-from tests import lib
f724ee
+from . import lib
f724ee
 
f724ee
 
f724ee
 class FakeDevice(object):
f724ee
diff --git a/tests/lib.py b/tests/devicelibs_test/lib.py
f724ee
similarity index 100%
f724ee
rename from tests/lib.py
f724ee
rename to tests/devicelibs_test/lib.py
f724ee
diff --git a/tests/formats_test/fs_test.py b/tests/formats_test/fs_test.py
f724ee
index ab3499a7..bd643370 100644
f724ee
--- a/tests/formats_test/fs_test.py
f724ee
+++ b/tests/formats_test/fs_test.py
f724ee
@@ -10,7 +10,7 @@ from blivet.errors import DeviceFormatError
f724ee
 from blivet.formats import get_format
f724ee
 from blivet.devices import PartitionDevice, DiskDevice
f724ee
 
f724ee
-from tests import loopbackedtestcase
f724ee
+from . import loopbackedtestcase
f724ee
 
f724ee
 from . import fstesting
f724ee
 
f724ee
diff --git a/tests/formats_test/fslabeling.py b/tests/formats_test/fslabeling.py
f724ee
index fbb28eee..0e0dc261 100644
f724ee
--- a/tests/formats_test/fslabeling.py
f724ee
+++ b/tests/formats_test/fslabeling.py
f724ee
@@ -2,7 +2,7 @@
f724ee
 import abc
f724ee
 import six
f724ee
 
f724ee
-from tests import loopbackedtestcase
f724ee
+from . import loopbackedtestcase
f724ee
 from blivet.errors import FSError, FSReadLabelError
f724ee
 from blivet.size import Size
f724ee
 
f724ee
diff --git a/tests/formats_test/fstesting.py b/tests/formats_test/fstesting.py
f724ee
index 86b2a116..e34584d8 100644
f724ee
--- a/tests/formats_test/fstesting.py
f724ee
+++ b/tests/formats_test/fstesting.py
f724ee
@@ -5,7 +5,7 @@ from six import add_metaclass
f724ee
 import os
f724ee
 import tempfile
f724ee
 
f724ee
-from tests import loopbackedtestcase
f724ee
+from . import loopbackedtestcase
f724ee
 from blivet.errors import FSError, FSResizeError, DeviceFormatError
f724ee
 from blivet.size import Size, ROUND_DOWN
f724ee
 from blivet.formats import fs
f724ee
diff --git a/tests/formats_test/fsuuid.py b/tests/formats_test/fsuuid.py
f724ee
index c8003945..16aa19a6 100644
f724ee
--- a/tests/formats_test/fsuuid.py
f724ee
+++ b/tests/formats_test/fsuuid.py
f724ee
@@ -3,7 +3,7 @@ import abc
f724ee
 import six
f724ee
 from unittest import skipIf
f724ee
 
f724ee
-from tests import loopbackedtestcase
f724ee
+from . import loopbackedtestcase
f724ee
 from blivet.errors import FSError, FSWriteUUIDError
f724ee
 from blivet.size import Size
f724ee
 from blivet.util import capture_output
f724ee
diff --git a/tests/formats_test/labeling_test.py b/tests/formats_test/labeling_test.py
f724ee
index e26cb7df..d24e6619 100644
f724ee
--- a/tests/formats_test/labeling_test.py
f724ee
+++ b/tests/formats_test/labeling_test.py
f724ee
@@ -1,10 +1,10 @@
f724ee
 import unittest
f724ee
 
f724ee
-from tests import loopbackedtestcase
f724ee
 from blivet.formats import device_formats
f724ee
 import blivet.formats.fs as fs
f724ee
 import blivet.formats.swap as swap
f724ee
 
f724ee
+from . import loopbackedtestcase
f724ee
 from . import fslabeling
f724ee
 
f724ee
 
f724ee
diff --git a/tests/loopbackedtestcase.py b/tests/formats_test/loopbackedtestcase.py
f724ee
similarity index 100%
f724ee
rename from tests/loopbackedtestcase.py
f724ee
rename to tests/formats_test/loopbackedtestcase.py
f724ee
diff --git a/tests/formats_test/luks_test.py b/tests/formats_test/luks_test.py
f724ee
index be0d50b0..5423ebdf 100644
f724ee
--- a/tests/formats_test/luks_test.py
f724ee
+++ b/tests/formats_test/luks_test.py
f724ee
@@ -7,7 +7,7 @@ from blivet.formats.luks import LUKS
f724ee
 
f724ee
 from blivet.size import Size
f724ee
 
f724ee
-from tests import loopbackedtestcase
f724ee
+from . import loopbackedtestcase
f724ee
 
f724ee
 
f724ee
 class LUKSTestCase(loopbackedtestcase.LoopBackedTestCase):
f724ee
diff --git a/tests/formats_test/lvmpv_test.py b/tests/formats_test/lvmpv_test.py
f724ee
index 792a2f1d..da7270d9 100644
f724ee
--- a/tests/formats_test/lvmpv_test.py
f724ee
+++ b/tests/formats_test/lvmpv_test.py
f724ee
@@ -4,7 +4,7 @@ from blivet.formats.lvmpv import LVMPhysicalVolume
f724ee
 
f724ee
 from blivet.size import Size
f724ee
 
f724ee
-from tests import loopbackedtestcase
f724ee
+from . import loopbackedtestcase
f724ee
 
f724ee
 
f724ee
 class LVMPVTestCase(loopbackedtestcase.LoopBackedTestCase):
f724ee
diff --git a/tests/partitioning_test.py b/tests/partitioning_test.py
f724ee
index b7aa5045..a713aaa1 100644
f724ee
--- a/tests/partitioning_test.py
f724ee
+++ b/tests/partitioning_test.py
f724ee
@@ -29,7 +29,7 @@ from blivet.devices.lvm import LVMCacheRequest
f724ee
 
f724ee
 from blivet.errors import PartitioningError
f724ee
 
f724ee
-from tests.imagebackedtestcase import ImageBackedTestCase
f724ee
+from imagebackedtestcase import ImageBackedTestCase
f724ee
 from blivet.blivet import Blivet
f724ee
 from blivet.util import sparsetmpfile
f724ee
 from blivet.formats import get_format
f724ee
-- 
f724ee
2.31.1
f724ee
f724ee
f724ee
From 9ee41c8b60c56ce752e305be73001c7089f43011 Mon Sep 17 00:00:00 2001
f724ee
From: Vojtech Trefny <vtrefny@redhat.com>
f724ee
Date: Fri, 6 Aug 2021 14:51:01 +0200
f724ee
Subject: [PATCH 3/3] tests: Print version and blivet location when running
f724ee
 tests
f724ee
f724ee
---
f724ee
 tests/run_tests.py | 5 +++++
f724ee
 1 file changed, 5 insertions(+)
f724ee
f724ee
diff --git a/tests/run_tests.py b/tests/run_tests.py
f724ee
index 32e3f2d3..8ad8b61a 100644
f724ee
--- a/tests/run_tests.py
f724ee
+++ b/tests/run_tests.py
f724ee
@@ -32,6 +32,11 @@ if __name__ == '__main__':
f724ee
 
f724ee
     testdir = os.path.abspath(os.path.dirname(__file__))
f724ee
 
f724ee
+    import blivet
f724ee
+    print("Running tests with Blivet %s from %s" % (blivet.__version__,
f724ee
+                                                    os.path.abspath(os.path.dirname(blivet.__file__))),
f724ee
+          file=sys.stderr)
f724ee
+
f724ee
     if args.testname:
f724ee
         for n in args.testname:
f724ee
             suite.addTests(unittest.TestLoader().loadTestsFromName(n))
f724ee
-- 
f724ee
2.31.1
f724ee