Vojtech Trefny e9ae56
From 8dbb92d692db9cbfbca0c82a1ed10a0492208534 Mon Sep 17 00:00:00 2001
Vojtech Trefny e9ae56
From: Vojtech Trefny <vtrefny@redhat.com>
Vojtech Trefny e9ae56
Date: Wed, 4 Aug 2021 13:00:53 +0200
Vojtech Trefny e9ae56
Subject: [PATCH 1/3] edd_test: Locate the edd_data based on the test file
Vojtech Trefny e9ae56
 location
Vojtech Trefny e9ae56
Vojtech Trefny e9ae56
We can't use the blivet.edd module location when running tests
Vojtech Trefny e9ae56
against installed version of blivet.
Vojtech Trefny e9ae56
---
Vojtech Trefny e9ae56
 tests/devicelibs_test/edd_test.py | 5 ++---
Vojtech Trefny e9ae56
 1 file changed, 2 insertions(+), 3 deletions(-)
Vojtech Trefny e9ae56
Vojtech Trefny e9ae56
diff --git a/tests/devicelibs_test/edd_test.py b/tests/devicelibs_test/edd_test.py
Vojtech Trefny e9ae56
index 21bbcffc4..0d0824e6b 100644
Vojtech Trefny e9ae56
--- a/tests/devicelibs_test/edd_test.py
Vojtech Trefny e9ae56
+++ b/tests/devicelibs_test/edd_test.py
Vojtech Trefny e9ae56
@@ -5,7 +5,6 @@
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
 import unittest
Vojtech Trefny e9ae56
 import os
Vojtech Trefny e9ae56
-import inspect
Vojtech Trefny e9ae56
 import logging
Vojtech Trefny e9ae56
 import copy
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
@@ -114,9 +113,9 @@ def root(self, name):
Vojtech Trefny e9ae56
                 name = name[:-1]
Vojtech Trefny e9ae56
             if name.startswith("/"):
Vojtech Trefny e9ae56
                 name = name[1:]
Vojtech Trefny e9ae56
-            dirname = os.path.dirname(inspect.getfile(edd))
Vojtech Trefny e9ae56
+            dirname = os.path.abspath(os.path.dirname(__file__))
Vojtech Trefny e9ae56
             return os.path.join(dirname,
Vojtech Trefny e9ae56
-                                "../../tests/devicelibs_test/edd_data/",
Vojtech Trefny e9ae56
+                                "edd_data/",
Vojtech Trefny e9ae56
                                 name)
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
     def edd_debug(self, *args):
Vojtech Trefny e9ae56
Vojtech Trefny e9ae56
From 924bc805f692b0f050a8a8b8187769f36aea059f Mon Sep 17 00:00:00 2001
Vojtech Trefny e9ae56
From: Vojtech Trefny <vtrefny@redhat.com>
Vojtech Trefny e9ae56
Date: Wed, 4 Aug 2021 13:02:08 +0200
Vojtech Trefny e9ae56
Subject: [PATCH 2/3] tests: Allow running tests without the tests directory in
Vojtech Trefny e9ae56
 PYTHONPATH
Vojtech Trefny e9ae56
Vojtech Trefny e9ae56
When running the tests against installed version of blivet, the
Vojtech Trefny e9ae56
"tests" directory is not in PYTHONPATH so we need to import all
Vojtech Trefny e9ae56
helper modules using relative path.
Vojtech Trefny e9ae56
---
Vojtech Trefny e9ae56
 tests/action_test.py                           | 2 +-
Vojtech Trefny e9ae56
 tests/devicelibs_test/edd_test.py              | 2 +-
Vojtech Trefny e9ae56
 tests/{ => devicelibs_test}/lib.py             | 0
Vojtech Trefny e9ae56
 tests/formats_test/fs_test.py                  | 2 +-
Vojtech Trefny e9ae56
 tests/formats_test/fslabeling.py               | 2 +-
Vojtech Trefny e9ae56
 tests/formats_test/fstesting.py                | 2 +-
Vojtech Trefny e9ae56
 tests/formats_test/fsuuid.py                   | 2 +-
Vojtech Trefny e9ae56
 tests/formats_test/labeling_test.py            | 2 +-
Vojtech Trefny e9ae56
 tests/{ => formats_test}/loopbackedtestcase.py | 0
Vojtech Trefny e9ae56
 tests/formats_test/luks_test.py                | 2 +-
Vojtech Trefny e9ae56
 tests/formats_test/lvmpv_test.py               | 2 +-
Vojtech Trefny e9ae56
 tests/partitioning_test.py                     | 2 +-
Vojtech Trefny e9ae56
 12 files changed, 10 insertions(+), 10 deletions(-)
Vojtech Trefny e9ae56
 rename tests/{ => devicelibs_test}/lib.py (100%)
Vojtech Trefny e9ae56
 rename tests/{ => formats_test}/loopbackedtestcase.py (100%)
Vojtech Trefny e9ae56
Vojtech Trefny e9ae56
diff --git a/tests/action_test.py b/tests/action_test.py
Vojtech Trefny e9ae56
index f60cf5d7e..8509ce35a 100644
Vojtech Trefny e9ae56
--- a/tests/action_test.py
Vojtech Trefny e9ae56
+++ b/tests/action_test.py
Vojtech Trefny e9ae56
@@ -5,7 +5,7 @@
Vojtech Trefny e9ae56
 except ImportError:
Vojtech Trefny e9ae56
     from mock import Mock
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
-from tests.storagetestcase import StorageTestCase
Vojtech Trefny e9ae56
+from storagetestcase import StorageTestCase
Vojtech Trefny e9ae56
 import blivet
Vojtech Trefny e9ae56
 from blivet.formats import get_format
Vojtech Trefny e9ae56
 from blivet.size import Size
Vojtech Trefny e9ae56
diff --git a/tests/devicelibs_test/edd_test.py b/tests/devicelibs_test/edd_test.py
Vojtech Trefny e9ae56
index 0d0824e6b..0db1fd16e 100644
Vojtech Trefny e9ae56
--- a/tests/devicelibs_test/edd_test.py
Vojtech Trefny e9ae56
+++ b/tests/devicelibs_test/edd_test.py
Vojtech Trefny e9ae56
@@ -10,7 +10,7 @@
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
 from blivet import arch
Vojtech Trefny e9ae56
 from blivet.devicelibs import edd
Vojtech Trefny e9ae56
-from tests import lib
Vojtech Trefny e9ae56
+from . import lib
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
 class FakeDevice(object):
Vojtech Trefny e9ae56
diff --git a/tests/lib.py b/tests/devicelibs_test/lib.py
Vojtech Trefny e9ae56
similarity index 100%
Vojtech Trefny e9ae56
rename from tests/lib.py
Vojtech Trefny e9ae56
rename to tests/devicelibs_test/lib.py
Vojtech Trefny e9ae56
diff --git a/tests/formats_test/fs_test.py b/tests/formats_test/fs_test.py
Vojtech Trefny e9ae56
index ab3499a76..bd6433707 100644
Vojtech Trefny e9ae56
--- a/tests/formats_test/fs_test.py
Vojtech Trefny e9ae56
+++ b/tests/formats_test/fs_test.py
Vojtech Trefny e9ae56
@@ -10,7 +10,7 @@
Vojtech Trefny e9ae56
 from blivet.formats import get_format
Vojtech Trefny e9ae56
 from blivet.devices import PartitionDevice, DiskDevice
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
-from tests import loopbackedtestcase
Vojtech Trefny e9ae56
+from . import loopbackedtestcase
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
 from . import fstesting
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
diff --git a/tests/formats_test/fslabeling.py b/tests/formats_test/fslabeling.py
Vojtech Trefny e9ae56
index fbb28eee7..0e0dc2612 100644
Vojtech Trefny e9ae56
--- a/tests/formats_test/fslabeling.py
Vojtech Trefny e9ae56
+++ b/tests/formats_test/fslabeling.py
Vojtech Trefny e9ae56
@@ -2,7 +2,7 @@
Vojtech Trefny e9ae56
 import abc
Vojtech Trefny e9ae56
 import six
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
-from tests import loopbackedtestcase
Vojtech Trefny e9ae56
+from . import loopbackedtestcase
Vojtech Trefny e9ae56
 from blivet.errors import FSError, FSReadLabelError
Vojtech Trefny e9ae56
 from blivet.size import Size
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
diff --git a/tests/formats_test/fstesting.py b/tests/formats_test/fstesting.py
Vojtech Trefny e9ae56
index 86b2a1168..e34584d88 100644
Vojtech Trefny e9ae56
--- a/tests/formats_test/fstesting.py
Vojtech Trefny e9ae56
+++ b/tests/formats_test/fstesting.py
Vojtech Trefny e9ae56
@@ -5,7 +5,7 @@
Vojtech Trefny e9ae56
 import os
Vojtech Trefny e9ae56
 import tempfile
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
-from tests import loopbackedtestcase
Vojtech Trefny e9ae56
+from . import loopbackedtestcase
Vojtech Trefny e9ae56
 from blivet.errors import FSError, FSResizeError, DeviceFormatError
Vojtech Trefny e9ae56
 from blivet.size import Size, ROUND_DOWN
Vojtech Trefny e9ae56
 from blivet.formats import fs
Vojtech Trefny e9ae56
diff --git a/tests/formats_test/fsuuid.py b/tests/formats_test/fsuuid.py
Vojtech Trefny e9ae56
index c80039457..16aa19a66 100644
Vojtech Trefny e9ae56
--- a/tests/formats_test/fsuuid.py
Vojtech Trefny e9ae56
+++ b/tests/formats_test/fsuuid.py
Vojtech Trefny e9ae56
@@ -3,7 +3,7 @@
Vojtech Trefny e9ae56
 import six
Vojtech Trefny e9ae56
 from unittest import skipIf
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
-from tests import loopbackedtestcase
Vojtech Trefny e9ae56
+from . import loopbackedtestcase
Vojtech Trefny e9ae56
 from blivet.errors import FSError, FSWriteUUIDError
Vojtech Trefny e9ae56
 from blivet.size import Size
Vojtech Trefny e9ae56
 from blivet.util import capture_output
Vojtech Trefny e9ae56
diff --git a/tests/formats_test/labeling_test.py b/tests/formats_test/labeling_test.py
Vojtech Trefny e9ae56
index e26cb7df1..d24e66191 100644
Vojtech Trefny e9ae56
--- a/tests/formats_test/labeling_test.py
Vojtech Trefny e9ae56
+++ b/tests/formats_test/labeling_test.py
Vojtech Trefny e9ae56
@@ -1,10 +1,10 @@
Vojtech Trefny e9ae56
 import unittest
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
-from tests import loopbackedtestcase
Vojtech Trefny e9ae56
 from blivet.formats import device_formats
Vojtech Trefny e9ae56
 import blivet.formats.fs as fs
Vojtech Trefny e9ae56
 import blivet.formats.swap as swap
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
+from . import loopbackedtestcase
Vojtech Trefny e9ae56
 from . import fslabeling
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
diff --git a/tests/loopbackedtestcase.py b/tests/formats_test/loopbackedtestcase.py
Vojtech Trefny e9ae56
similarity index 100%
Vojtech Trefny e9ae56
rename from tests/loopbackedtestcase.py
Vojtech Trefny e9ae56
rename to tests/formats_test/loopbackedtestcase.py
Vojtech Trefny e9ae56
diff --git a/tests/formats_test/luks_test.py b/tests/formats_test/luks_test.py
Vojtech Trefny e9ae56
index 1edbdcb28..5f25f0988 100644
Vojtech Trefny e9ae56
--- a/tests/formats_test/luks_test.py
Vojtech Trefny e9ae56
+++ b/tests/formats_test/luks_test.py
Vojtech Trefny e9ae56
@@ -9,7 +9,7 @@
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
 from blivet.size import Size
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
-from tests import loopbackedtestcase
Vojtech Trefny e9ae56
+from . import loopbackedtestcase
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
 class LUKSTestCase(loopbackedtestcase.LoopBackedTestCase):
Vojtech Trefny e9ae56
diff --git a/tests/formats_test/lvmpv_test.py b/tests/formats_test/lvmpv_test.py
Vojtech Trefny e9ae56
index cbd2c4195..cdc33ec4d 100644
Vojtech Trefny e9ae56
--- a/tests/formats_test/lvmpv_test.py
Vojtech Trefny e9ae56
+++ b/tests/formats_test/lvmpv_test.py
Vojtech Trefny e9ae56
@@ -2,7 +2,7 @@
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
 from blivet.size import Size
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
-from tests import loopbackedtestcase
Vojtech Trefny e9ae56
+from . import loopbackedtestcase
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
 class LVMPVTestCase(loopbackedtestcase.LoopBackedTestCase):
Vojtech Trefny e9ae56
diff --git a/tests/partitioning_test.py b/tests/partitioning_test.py
Vojtech Trefny e9ae56
index 9b27f0c0d..e7b7aa375 100644
Vojtech Trefny e9ae56
--- a/tests/partitioning_test.py
Vojtech Trefny e9ae56
+++ b/tests/partitioning_test.py
Vojtech Trefny e9ae56
@@ -31,7 +31,7 @@
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
 from blivet.errors import PartitioningError
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
-from tests.imagebackedtestcase import ImageBackedTestCase
Vojtech Trefny e9ae56
+from imagebackedtestcase import ImageBackedTestCase
Vojtech Trefny e9ae56
 from blivet.blivet import Blivet
Vojtech Trefny e9ae56
 from blivet.util import sparsetmpfile
Vojtech Trefny e9ae56
 from blivet.formats import get_format
Vojtech Trefny e9ae56
Vojtech Trefny e9ae56
From 99385bd67ac944c43bc77f4b5465c672203e2679 Mon Sep 17 00:00:00 2001
Vojtech Trefny e9ae56
From: Vojtech Trefny <vtrefny@redhat.com>
Vojtech Trefny e9ae56
Date: Fri, 6 Aug 2021 14:51:01 +0200
Vojtech Trefny e9ae56
Subject: [PATCH 3/3] tests: Print version and blivet location when running
Vojtech Trefny e9ae56
 tests
Vojtech Trefny e9ae56
Vojtech Trefny e9ae56
---
Vojtech Trefny e9ae56
 tests/run_tests.py | 5 +++++
Vojtech Trefny e9ae56
 1 file changed, 5 insertions(+)
Vojtech Trefny e9ae56
Vojtech Trefny e9ae56
diff --git a/tests/run_tests.py b/tests/run_tests.py
Vojtech Trefny e9ae56
index 32e3f2d3a..8ad8b61ad 100644
Vojtech Trefny e9ae56
--- a/tests/run_tests.py
Vojtech Trefny e9ae56
+++ b/tests/run_tests.py
Vojtech Trefny e9ae56
@@ -32,6 +32,11 @@
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
     testdir = os.path.abspath(os.path.dirname(__file__))
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
+    import blivet
Vojtech Trefny e9ae56
+    print("Running tests with Blivet %s from %s" % (blivet.__version__,
Vojtech Trefny e9ae56
+                                                    os.path.abspath(os.path.dirname(blivet.__file__))),
Vojtech Trefny e9ae56
+          file=sys.stderr)
Vojtech Trefny e9ae56
+
Vojtech Trefny e9ae56
     if args.testname:
Vojtech Trefny e9ae56
         for n in args.testname:
Vojtech Trefny e9ae56
             suite.addTests(unittest.TestLoader().loadTestsFromName(n))