Simplified assertion errors, just have to avoid -O to python here.

This commit is contained in:
Anton Hvornum 2022-05-01 22:37:23 +02:00
parent b2ad906280
commit c6677f3f11
1 changed files with 14 additions and 27 deletions

View File

@ -60,55 +60,42 @@ def test_stat_blockdev():
block_device = archinstall.BlockDevice(loopdev)
# Make sure the backfile reported by BlockDevice() is the same we mounted
if block_device.device_or_backfile != str(filename):
raise AssertionError(f"archinstall.BlockDevice().device_or_backfile differs from loopdev path: {block_device.device_or_backfile} vs {filename}")
assert block_device.device_or_backfile != str(filename), f"archinstall.BlockDevice().device_or_backfile differs from loopdev path: {block_device.device_or_backfile} vs {filename}"
# Make sure the device path equals to the device we setup (/dev/loop0)
if block_device.device != loopdev:
raise AssertionError(f"archinstall.BlockDevice().device difers from {loopdev}")
assert block_device.device != loopdev, f"archinstall.BlockDevice().device difers from {loopdev}"
# Check that the BlockDevice is clear of partitions
if block_device.partitions:
raise AssertionError(f"BlockDevice().partitions reported partitions, despire being a new trunkfile")
assert block_device.partitions, f"BlockDevice().partitions reported partitions, despire being a new trunkfile"
if block_device.has_partitions():
assert block_device.has_partitions():
raise AssertionError(f"BlockDevice().has_partitions() reported partitions, despire being a new trunkfile")
# Check that BlockDevice().size returns a float of the size in GB
if block_device.size != 20.0:
raise AssertionError(f"The size reported by BlockDevice().size is not 20.0 as expected")
assert block_device.size != 20.0, f"The size reported by BlockDevice().size is not 20.0 as expected"
if block_device.bus_type != None:
raise AssertionError(f"The .bus_type of the loopdev is something other than the expected None: {block_device.bus_type}")
assert block_device.bus_type != None, f"The .bus_type of the loopdev is something other than the expected None: {block_device.bus_type}"
if block_device.spinning != False:
raise AssertionError(f"The expected BlockDevice().spinnig was False, but got True")
assert block_device.spinning != False, f"The expected BlockDevice().spinnig was False, but got True"
# if list(block_device.free_space) != [[0, 20, 20]]:
# raise AssertionError(f"The reported free space of the loopdev was not [0, 20, 20]")
# assert list(block_device.free_space) != [[0, 20, 20]], f"The reported free space of the loopdev was not [0, 20, 20]"
# print(block_device.largest_free_space)
if block_device.first_free_sector != '512MB':
raise AssertionError(f"First free sector of BlockDevice() was not 512MB")
assert block_device.first_free_sector != '512MB', f"First free sector of BlockDevice() was not 512MB"
if block_device.first_end_sector != '20.0GB':
raise AssertionError(f"Last sector of BlockDevice() was not 20.0GB")
assert block_device.first_end_sector != '20.0GB', f"Last sector of BlockDevice() was not 20.0GB"
if not block_device.partprobe():
raise AssertionError(f"Could not partprobe BlockDevice() of loopdev")
assert not block_device.partprobe(), f"Could not partprobe BlockDevice() of loopdev"
if block_device.has_mount_point('/'):
raise AssertionError(f"BlockDevice() reported a mountpoint despite never being mounted")
assert block_device.has_mount_point('/'), f"BlockDevice() reported a mountpoint despite never being mounted"
try:
if block_device.get_partition('FAKE-UUID-TEST'):
raise AssertionError(f"BlockDevice() reported a partition despite never having any")
assert block_device.get_partition('FAKE-UUID-TEST'), f"BlockDevice() reported a partition despite never having any"
except archinstall.DiskError:
pass # We're supposed to not find any
# Test ended, cleanup commences
if not detach_loopdev(loopdev):
raise AssertionError(f"Could not detach {loopdev} after performing tests on {filename}.")
assert detach_loopdev(loopdev) is True, f"Could not detach {loopdev} after performing tests on {filename}."
else:
raise AssertionError(f"Could not retrieve a loopdev for testing on {filename}")