Skip to content

Commit b6a21c3

Browse files
authored
Merge pull request #274 from xcp-ng/fix3.8
guest-tools/win: Fix type hint compatibility with Python 3.8
2 parents 134fd55 + e9c8017 commit b6a21c3

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

tests/guest-tools/win/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import logging
33
import re
44
import time
5-
from typing import Any
5+
from typing import Any, Dict, Union
66

77
from data import ISO_DOWNLOAD_URL
88
from lib.commands import SSHCommandFailed
@@ -23,7 +23,7 @@ class PowerAction(enum.Enum):
2323
Reboot = "reboot"
2424

2525

26-
def iso_create(host: Host, sr: SR, param: dict[str, Any]):
26+
def iso_create(host: Host, sr: SR, param: Dict[str, Any]):
2727
if param["download"]:
2828
vdi = host.import_iso(ISO_DOWNLOAD_URL + param["name"], sr)
2929
new_param = param.copy()
@@ -55,7 +55,7 @@ def wait_for_vm_running_and_ssh_up_without_tools(vm: VM):
5555
wait_for(vm.is_ssh_up, "Wait for SSH up")
5656

5757

58-
def enable_testsign(vm: VM, rootcert: str | None):
58+
def enable_testsign(vm: VM, rootcert: Union[str, None]):
5959
if rootcert is not None:
6060
vm.execute_powershell_script(
6161
f"""certutil -addstore -f Root '{rootcert}';

tests/guest-tools/win/conftest.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import logging
2-
from typing import Any
2+
from typing import Any, Dict, Tuple
33
import pytest
44

55
from data import OTHER_GUEST_TOOLS, OTHER_GUEST_TOOLS_ISO, WIN_GUEST_TOOLS_ISOS
@@ -47,7 +47,7 @@ def unsealed_windows_vm_and_snapshot(running_windows_vm_without_tools: VM):
4747

4848

4949
@pytest.fixture
50-
def running_unsealed_windows_vm(unsealed_windows_vm_and_snapshot: tuple[VM, Snapshot]):
50+
def running_unsealed_windows_vm(unsealed_windows_vm_and_snapshot: Tuple[VM, Snapshot]):
5151
vm, snapshot = unsealed_windows_vm_and_snapshot
5252
vm.start()
5353
wait_for_vm_running_and_ssh_up_without_tools(vm)
@@ -56,7 +56,7 @@ def running_unsealed_windows_vm(unsealed_windows_vm_and_snapshot: tuple[VM, Snap
5656

5757

5858
@pytest.fixture(scope="class")
59-
def vm_install_test_tools_per_test_class(unsealed_windows_vm_and_snapshot, guest_tools_iso: dict[str, Any]):
59+
def vm_install_test_tools_per_test_class(unsealed_windows_vm_and_snapshot, guest_tools_iso: Dict[str, Any]):
6060
vm, snapshot = unsealed_windows_vm_and_snapshot
6161
vm.start()
6262
wait_for_vm_running_and_ssh_up_without_tools(vm)
@@ -66,7 +66,7 @@ def vm_install_test_tools_per_test_class(unsealed_windows_vm_and_snapshot, guest
6666

6767

6868
@pytest.fixture
69-
def vm_install_test_tools_no_reboot(running_unsealed_windows_vm: VM, guest_tools_iso: dict[str, Any]):
69+
def vm_install_test_tools_no_reboot(running_unsealed_windows_vm: VM, guest_tools_iso: Dict[str, Any]):
7070
install_guest_tools(running_unsealed_windows_vm, guest_tools_iso, PowerAction.Nothing)
7171
return running_unsealed_windows_vm
7272

@@ -87,8 +87,8 @@ def other_tools_iso(host: Host, nfs_iso_sr: SR):
8787

8888
@pytest.fixture(ids=list(OTHER_GUEST_TOOLS.keys()), params=list(OTHER_GUEST_TOOLS.values()))
8989
def vm_install_other_drivers(
90-
unsealed_windows_vm_and_snapshot: tuple[VM, Snapshot],
91-
other_tools_iso: dict[str, Any],
90+
unsealed_windows_vm_and_snapshot: Tuple[VM, Snapshot],
91+
other_tools_iso: Dict[str, Any],
9292
request: pytest.FixtureRequest,
9393
):
9494
vm, snapshot = unsealed_windows_vm_and_snapshot

tests/guest-tools/win/guest_tools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22
from pathlib import PureWindowsPath
3-
from typing import Any
3+
from typing import Any, Dict
44

55
from lib.common import wait_for
66
from lib.vm import VM
@@ -21,7 +21,7 @@
2121
GUEST_TOOLS_COPY_PATH = "C:\\package.msi"
2222

2323

24-
def install_guest_tools(vm: VM, guest_tools_iso: dict[str, Any], action: PowerAction, check: bool = True):
24+
def install_guest_tools(vm: VM, guest_tools_iso: Dict[str, Any], action: PowerAction, check: bool = True):
2525
insert_cd_safe(vm, guest_tools_iso["name"])
2626

2727
if guest_tools_iso.get("testsign_cert"):

tests/guest-tools/win/other_tools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import logging
22
from pathlib import PureWindowsPath
3-
from typing import Any
3+
from typing import Any, Dict
44

55
from lib.common import wait_for
66
from lib.vm import VM
77
from . import WINDOWS_SHUTDOWN_COMMAND, enable_testsign, insert_cd_safe, wait_for_vm_running_and_ssh_up_without_tools
88

99

10-
def install_other_drivers(vm: VM, other_tools_iso_name: str, param: dict[str, Any]):
10+
def install_other_drivers(vm: VM, other_tools_iso_name: str, param: Dict[str, Any]):
1111
if param.get("vendor_device"):
1212
assert not vm.param_get("has-vendor-device")
1313
vm.param_set("has-vendor-device", True)

tests/guest-tools/win/test_xenclean.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import logging
22
from pathlib import PureWindowsPath
3-
from typing import Any
3+
from typing import Any, Dict
44
import pytest
55
from lib.common import wait_for
66
from lib.vm import VM
77

88
from . import WINDOWS_SHUTDOWN_COMMAND, insert_cd_safe, wait_for_vm_running_and_ssh_up_without_tools
99

1010

11-
def run_xenclean(vm: VM, guest_tools_iso: dict[str, Any]):
11+
def run_xenclean(vm: VM, guest_tools_iso: Dict[str, Any]):
1212
insert_cd_safe(vm, guest_tools_iso["name"])
1313

1414
logging.info("Run XenClean")

0 commit comments

Comments
 (0)