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