]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume/tests: address nose tests deprecation 52071/head
authorGuillaume Abrioux <gabrioux@ibm.com>
Mon, 27 Mar 2023 12:36:10 +0000 (14:36 +0200)
committerGuillaume Abrioux <gabrioux@ibm.com>
Thu, 15 Jun 2023 07:09:57 +0000 (09:09 +0200)
migrate setup/teardown from nosetest to native pytest.

see [1]

[1] https://docs.pytest.org/en/stable/deprecations.html#support-for-tests-written-for-nose

Signed-off-by: Guillaume Abrioux <gabrioux@ibm.com>
(cherry picked from commit 2f781217467ac99c1adf4df2b5fb43a5566b1c87)

src/ceph-volume/ceph_volume/tests/api/test_lvm.py
src/ceph-volume/ceph_volume/tests/devices/lvm/test_zap.py
src/ceph-volume/ceph_volume/tests/devices/simple/test_scan.py
src/ceph-volume/ceph_volume/tests/systemd/test_main.py
src/ceph-volume/ceph_volume/tests/test_configuration.py
src/ceph-volume/ceph_volume/tests/test_decorators.py
src/ceph-volume/ceph_volume/tests/test_terminal.py
src/ceph-volume/ceph_volume/tests/util/test_arg_validators.py
src/ceph-volume/ceph_volume/tests/util/test_device.py
src/ceph-volume/ceph_volume/tests/util/test_system.py

index 0bfc34075c31c41b8569f5be57d357e4b906f044..603b2b85476eb8d2f4c54814b87141741896816c 100644 (file)
@@ -69,7 +69,7 @@ class TestVolumeGroupFree(object):
 
 class TestCreateLVs(object):
 
-    def setup(self):
+    def setup_method(self):
         self.vg = api.VolumeGroup(vg_name='ceph',
                                          vg_extent_size=1073741824,
                                          vg_extent_count=99999999,
@@ -107,7 +107,7 @@ class TestCreateLVs(object):
 
 class TestVolumeGroupSizing(object):
 
-    def setup(self):
+    def setup_method(self):
         self.vg = api.VolumeGroup(vg_name='ceph',
                                          vg_extent_size=1073741824,
                                          vg_free_count=1024)
@@ -182,7 +182,7 @@ class TestRemoveLV(object):
 
 class TestCreateLV(object):
 
-    def setup(self):
+    def setup_method(self):
         self.foo_volume = api.Volume(lv_name='foo', lv_path='/path', vg_name='foo_group', lv_tags='')
         self.foo_group = api.VolumeGroup(vg_name='foo_group',
                                          vg_extent_size="4194304",
@@ -294,7 +294,7 @@ class TestCreateLV(object):
 
 class TestTags(object):
 
-    def setup(self):
+    def setup_method(self):
         self.foo_volume_clean = api.Volume(lv_name='foo_clean', lv_path='/pathclean',
             vg_name='foo_group',
             lv_tags='')
@@ -373,7 +373,7 @@ class TestTags(object):
 
 class TestExtendVG(object):
 
-    def setup(self):
+    def setup_method(self):
         self.foo_volume = api.VolumeGroup(vg_name='foo', lv_tags='')
 
     def test_uses_single_device_in_list(self, monkeypatch, fake_run):
@@ -397,7 +397,7 @@ class TestExtendVG(object):
 
 class TestReduceVG(object):
 
-    def setup(self):
+    def setup_method(self):
         self.foo_volume = api.VolumeGroup(vg_name='foo', lv_tags='')
 
     def test_uses_single_device_in_list(self, monkeypatch, fake_run):
@@ -421,7 +421,7 @@ class TestReduceVG(object):
 
 class TestCreateVG(object):
 
-    def setup(self):
+    def setup_method(self):
         self.foo_volume = api.VolumeGroup(vg_name='foo', lv_tags='')
 
     def test_no_name(self, monkeypatch, fake_run):
index 64016111c26317098bdadf5864835e26aaa6e392..2446c5ed6651e36aacb081677deef856cfb47ee8 100644 (file)
@@ -220,7 +220,7 @@ class TestEnsureAssociatedLVs(object):
 
 class TestWipeFs(object):
 
-    def setup(self):
+    def setup_method(self):
         os.environ['CEPH_VOLUME_WIPEFS_INTERVAL'] = '0'
 
     def test_works_on_second_try(self, stub_call):
index b5d12065578534159763c51ad3bf5a2658efe843..598e8249a693b2788a3a9686beef34e9432df48e 100644 (file)
@@ -5,7 +5,7 @@ from ceph_volume.devices.simple import scan
 
 class TestGetContents(object):
 
-    def setup(self):
+    def setup_method(self):
         self.magic_file_name = '/tmp/magic-file'
 
     def test_multiple_lines_are_left_as_is(self, fake_filesystem):
index 0af52e8d141c7d7a5a30a570c33645bc5494d40e..be13438f6fb6c04db7af8b64e92d52cd72dd7d6e 100644 (file)
@@ -28,7 +28,7 @@ class Capture(object):
 
 class TestMain(object):
 
-    def setup(self):
+    def setup_method(self):
         conf.log_path = '/tmp/'
 
     def test_no_arguments_parsing_error(self):
index 9af6cd9bedf81114b6fd6d1de94bc710606e1d2e..83eea1eb8d3aefe1b7004ed827e9e788c3d1f819 100644 (file)
@@ -19,7 +19,7 @@ tabbed_conf = """
 
 class TestConf(object):
 
-    def setup(self):
+    def setup_method(self):
         self.conf_file = StringIO(dedent("""
         [foo]
         default = 0
index 5bdf6b3d27bf98261d26d402471de975fe2a0286..a56f7030b4cb52a50f5d976437d2a2685e1d9caf 100644 (file)
@@ -46,7 +46,7 @@ class TestExceptionMessage(object):
 
 class TestCatches(object):
 
-    def teardown(self):
+    def teardown_method(self):
         try:
             del(os.environ['CEPH_VOLUME_DEBUG'])
         except KeyError:
index fdf219070579041c12e61de22f6b001f3509cd8e..e59a036baa80efbd8ef7b07d8446e6ea485db2b1 100644 (file)
@@ -100,7 +100,7 @@ def stream():
 
 class TestWriteUnicode(object):
 
-    def setup(self):
+    def setup_method(self):
         self.octpus_and_squid_en = u'octpus and squid'
         self.octpus_and_squid_zh = u'章鱼和鱿鱼'
         self.message = self.octpus_and_squid_en + self.octpus_and_squid_zh
index b0446a13b4685a6780cbb23a661b151d664a9d87..c6349308ee7a4b6e900e53625cc360004164c647 100644 (file)
@@ -8,7 +8,7 @@ from mock.mock import patch, MagicMock
 
 class TestOSDPath(object):
 
-    def setup(self):
+    def setup_method(self):
         self.validator = arg_validators.OSDPath()
 
     def test_is_not_root(self, monkeypatch):
@@ -34,7 +34,7 @@ class TestOSDPath(object):
 
 class TestExcludeGroupOptions(object):
 
-    def setup(self):
+    def setup_method(self):
         self.parser = argparse.ArgumentParser()
 
     def test_flags_in_one_group(self):
@@ -79,7 +79,7 @@ class TestExcludeGroupOptions(object):
 
 class TestValidDevice(object):
 
-    def setup(self, fake_filesystem):
+    def setup_method(self, fake_filesystem):
         self.validator = arg_validators.ValidDevice()
 
     @patch('ceph_volume.util.arg_validators.disk.has_bluestore_label', return_value=False)
@@ -113,7 +113,7 @@ class TestValidDevice(object):
             self.validator('/dev/foo')
 
 class TestValidZapDevice(object):
-    def setup(self):
+    def setup_method(self):
         self.validator = arg_validators.ValidZapDevice()
 
     @patch('ceph_volume.util.arg_validators.Device')
@@ -146,7 +146,7 @@ class TestValidZapDevice(object):
         assert self.validator('/dev/foo')
 
 class TestValidDataDevice(object):
-    def setup(self):
+    def setup_method(self):
         self.validator = arg_validators.ValidDataDevice()
 
     @patch('ceph_volume.util.arg_validators.Device')
@@ -194,7 +194,7 @@ class TestValidDataDevice(object):
             self.validator('/dev/foo')
 
 class TestValidRawDevice(object):
-    def setup(self):
+    def setup_method(self):
         self.validator = arg_validators.ValidRawDevice()
 
     @patch('ceph_volume.util.arg_validators.Device')
@@ -268,7 +268,7 @@ class TestValidRawDevice(object):
             assert self.validator('/dev/foo')
 
 class TestValidBatchDevice(object):
-    def setup(self):
+    def setup_method(self):
         self.validator = arg_validators.ValidBatchDevice()
 
     @patch('ceph_volume.util.arg_validators.Device')
@@ -303,7 +303,7 @@ class TestValidBatchDevice(object):
         assert self.validator('/dev/foo')
 
 class TestValidBatchDataDevice(object):
-    def setup(self):
+    def setup_method(self):
         self.validator = arg_validators.ValidBatchDataDevice()
 
     @patch('ceph_volume.util.arg_validators.Device')
@@ -340,7 +340,7 @@ class TestValidBatchDataDevice(object):
 
 class TestValidFraction(object):
 
-    def setup(self):
+    def setup_method(self):
         self.validator = arg_validators.ValidFraction()
 
     def test_fraction_is_valid(self, fake_call):
index 8eef3ff00c1d9ce94258b1762360caa9f0bb58e5..e382981d9232e6b331b468907228e39a42b3c3b6 100644 (file)
@@ -592,7 +592,7 @@ class TestDeviceEncryption(object):
 
 class TestDeviceOrdering(object):
 
-    def setup(self):
+    def setup_method(self):
         self.data = {
                 "/dev/sda": {"removable": 0},
                 "/dev/sdb": {"removable": 1}, # invalid
index 5746f7023ce5f904b2480c6b01b7bf4b20beb92b..d599271035b3a66c4cc7acd9c100d7216fa9c0d7 100644 (file)
@@ -264,7 +264,7 @@ except NameError:
 
 class TestSetContext(object):
 
-    def setup(self):
+    def setup_method(self):
         try:
             os.environ.pop('CEPH_VOLUME_SKIP_RESTORECON')
         except KeyError: