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