From aa2898c94a13eb2850ba918a76d4d3607951ba03 Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Thu, 22 Jan 2026 14:38:13 +0000 Subject: [PATCH] ceph-volume: update argparse help output assertions for python compatibility This commit updates test assertions to be more flexible about argparse help output format. It replaces checks for 'optional arguments' and 'positional arguments' with checks for 'positional' and help flags ('-h' or '--help'), which works across different python versions where argparse output format may differ. Signed-off-by: Guillaume Abrioux --- src/ceph-volume/ceph_volume/tests/devices/lvm/test_prepare.py | 4 ++-- src/ceph-volume/ceph_volume/tests/devices/test_zap.py | 3 ++- src/ceph-volume/ceph_volume/tests/util/test_device.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ceph-volume/ceph_volume/tests/devices/lvm/test_prepare.py b/src/ceph-volume/ceph_volume/tests/devices/lvm/test_prepare.py index 89843d3f66b6..e85250d3dbc2 100644 --- a/src/ceph-volume/ceph_volume/tests/devices/lvm/test_prepare.py +++ b/src/ceph-volume/ceph_volume/tests/devices/lvm/test_prepare.py @@ -56,5 +56,5 @@ class TestActivate(object): with pytest.raises(SystemExit): lvm.activate.Activate(argv=['--help']).main() stdout, stderr = capsys.readouterr() - assert 'optional arguments' in stdout - assert 'positional arguments' in stdout + assert 'positional' in stdout + assert '-h' in stdout or '--help' in stdout diff --git a/src/ceph-volume/ceph_volume/tests/devices/test_zap.py b/src/ceph-volume/ceph_volume/tests/devices/test_zap.py index 5f72ea0221b9..d54ac7314443 100644 --- a/src/ceph-volume/ceph_volume/tests/devices/test_zap.py +++ b/src/ceph-volume/ceph_volume/tests/devices/test_zap.py @@ -14,7 +14,8 @@ class TestZap(object): with pytest.raises(SystemExit): lvm.zap.Zap(argv=['--help']).main() stdout, stderr = capsys.readouterr() - assert 'optional arguments' in stdout + assert 'positional' in stdout + assert '-h' in stdout or '--help' in stdout @pytest.mark.parametrize('device_name', [ '/dev/mapper/foo', diff --git a/src/ceph-volume/ceph_volume/tests/util/test_device.py b/src/ceph-volume/ceph_volume/tests/util/test_device.py index e238cdfb6677..ea7d97e1634d 100644 --- a/src/ceph-volume/ceph_volume/tests/util/test_device.py +++ b/src/ceph-volume/ceph_volume/tests/util/test_device.py @@ -306,7 +306,7 @@ class TestDevice(object): @patch("ceph_volume.util.disk.has_bluestore_label", lambda x: False) def test_reject_readonly_device(self, fake_call, device_info): - data = {"/dev/cdrom": {"ro": "1"}} + data = {"/dev/cdrom": {"ro": "1", "partitions": {}}} lsblk = {"TYPE": "disk", "NAME": "cdrom"} device_info(devices=data,lsblk=lsblk) disk = device.Device("/dev/cdrom") -- 2.47.3