mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
storage: tests: Fix a test failure for psutils >= 7.0
- We are using a private data structure that lead to failure. psutil 7.0 removed two fields from the partition class. Just update the code to work with 7.0 instead of emulating psutil completely as that is a better test. - The primary code is unaffected in is_partition_read_only() and get_filesystem_type() due to not having any changes in the fields we use. Tests: - Run unit tests on testing and unstable VMs. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
df8d41e7fb
commit
aa181a564f
@ -375,7 +375,16 @@ def test_validate_directory_creatable(path, error):
|
||||
@patch('psutil.disk_partitions')
|
||||
def test_is_partition_read_only(disk_partitions):
|
||||
"""Test whether checking for ro partition works."""
|
||||
partition = psutil._common.sdiskpart # pylint: disable=protected-access
|
||||
|
||||
def partition(*args):
|
||||
try:
|
||||
# psutil <= 5.9.8
|
||||
# pylint: disable=protected-access
|
||||
return psutil._common.sdiskpart(*args)
|
||||
except TypeError:
|
||||
# psutil >= 7.0
|
||||
return psutil._common.sdiskpart(*args[:-2])
|
||||
|
||||
disk_partitions.return_value = [
|
||||
partition('/dev/root', '/', 'btrfs', 'rw,nosuid', 42, 42),
|
||||
partition('/dev/root', '/foo', 'btrfs', 'rw', 321, 321),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user