aboutsummaryrefslogtreecommitdiff
path: root/python/qemu/qtest.py
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2020-10-06 19:58:06 -0400
committerJohn Snow <jsnow@redhat.com>2020-10-20 09:37:57 -0400
commitaad3f3bb6c8b63b33db30911748fe32928b7b4bd (patch)
tree8b05fc8b5e6fa38a88f7609ce3efa2c9daf4c36f /python/qemu/qtest.py
parent9223fda464690b83a2b1f1487163f50602454c2e (diff)
downloadqemu-aad3f3bb6c8b63b33db30911748fe32928b7b4bd.zip
qemu-aad3f3bb6c8b63b33db30911748fe32928b7b4bd.tar.gz
qemu-aad3f3bb6c8b63b33db30911748fe32928b7b4bd.tar.bz2
python/qemu: make 'args' style arguments immutable
These arguments don't need to be mutable and aren't really used as such. Clarify their types as immutable and adjust code to match where necessary. In general, It's probably best not to accept a user-defined mutable object and store it as internal object state unless there's a strong justification for doing so. Instead, try to use generic types as input with empty tuples as the default, and coerce to list where necessary. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-id: 20201006235817.3280413-10-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
Diffstat (limited to 'python/qemu/qtest.py')
-rw-r--r--python/qemu/qtest.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/python/qemu/qtest.py b/python/qemu/qtest.py
index 7fde256..675310d 100644
--- a/python/qemu/qtest.py
+++ b/python/qemu/qtest.py
@@ -19,7 +19,12 @@ subclass of QEMUMachine, respectively.
import os
import socket
-from typing import List, Optional, TextIO
+from typing import (
+ List,
+ Optional,
+ Sequence,
+ TextIO,
+)
from .machine import QEMUMachine
@@ -99,8 +104,13 @@ class QEMUQtestMachine(QEMUMachine):
A QEMU VM, with a qtest socket available.
"""
- def __init__(self, binary, args=None, name=None, test_dir="/var/tmp",
- socket_scm_helper=None, sock_dir=None):
+ def __init__(self,
+ binary: str,
+ args: Sequence[str] = (),
+ name: Optional[str] = None,
+ test_dir: str = "/var/tmp",
+ socket_scm_helper: Optional[str] = None,
+ sock_dir: Optional[str] = None):
if name is None:
name = "qemu-%d" % os.getpid()
if sock_dir is None:
@@ -114,8 +124,10 @@ class QEMUQtestMachine(QEMUMachine):
@property
def _base_args(self) -> List[str]:
args = super()._base_args
- args.extend(['-qtest', 'unix:path=' + self._qtest_path,
- '-accel', 'qtest'])
+ args.extend([
+ '-qtest', f"unix:path={self._qtest_path}",
+ '-accel', 'qtest'
+ ])
return args
def _pre_launch(self):