19
19
import os .path
20
20
import re
21
21
import textwrap
22
+ import unittest
22
23
from typing import Any
23
24
24
25
from machine import testvm
@@ -29,7 +30,7 @@ def from_udisks_ascii(codepoints: list[int]) -> str:
29
30
return '' .join (map (chr , codepoints [:- 1 ]))
30
31
31
32
32
- class StorageHelpers :
33
+ class StorageHelpers ( unittest . TestCase ) :
33
34
"""Mix-in class for using in tests that derive from something else than MachineCase or StorageCase"""
34
35
machine : testvm .Machine
35
36
browser : Browser
@@ -70,7 +71,7 @@ def add_ram_disk(self, size: int = 50, delay: int | None = None):
70
71
71
72
return dev
72
73
73
- def add_loopback_disk (self , size = 50 , name = None ):
74
+ def add_loopback_disk (self , size : int = 50 , name : str | None = None ) -> str :
74
75
"""Add per-test loopback disk
75
76
76
77
The disk gets removed automatically when the test ends. This is safe for @nondestructive tests.
@@ -103,7 +104,7 @@ def add_loopback_disk(self, size=50, name=None):
103
104
104
105
return dev
105
106
106
- def add_targetd_loopback_disk (self , index , size = 50 ):
107
+ def add_targetd_loopback_disk (self , index : str , size : int = 50 ) -> str :
107
108
"""Add per-test loopback device that can be forcefully removed.
108
109
"""
109
110
@@ -135,12 +136,12 @@ def force_remove_disk(self, device: str) -> None:
135
136
# the removal trips up PCP and our usage graphs
136
137
self .allow_browser_errors ("direct: instance name lookup failed.*" )
137
138
138
- def addCleanupVG (self , vgname ) :
139
+ def addCleanupVG (self , vgname : str ) -> None :
139
140
"""Ensure the given VG is removed after the test"""
140
141
141
142
self .addCleanup (self .machine .execute , f"if [ -d /dev/{ vgname } ]; then vgremove --force { vgname } ; fi" )
142
143
143
- def addCleanupMount (self , mount_point ) :
144
+ def addCleanupMount (self , mount_point : str ) -> None :
144
145
self .addCleanup (self .machine .execute ,
145
146
f"if mountpoint -q { mount_point } ; then umount { mount_point } ; fi" )
146
147
0 commit comments