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