qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 10/10] qemu-iotests/118: Test media change with


From: Sascha Silbe
Subject: Re: [Qemu-devel] [PATCH 10/10] qemu-iotests/118: Test media change with qdev name
Date: Thu, 15 Sep 2016 18:16:37 +0200
User-agent: Notmuch/0.22.1~rc0 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-pc-linux-gnu)

Dear Eric,

(replying only to the Python coding part, haven't looked at the patch
itself)

Eric Blake <address@hidden> writes:

> On 08/19/2016 11:50 AM, Kevin Wolf wrote:
>> @@ -76,9 +79,15 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass):
>>          self.assert_qmp(result, 'return[0]/inserted/image/filename', 
>> new_img)
>>  
>>      def test_blockdev_change_medium(self):
>> -        result = self.vm.qmp('blockdev-change-medium', device='drive0',
>> -                                                       filename=new_img,
>> -                                                       
>> format=iotests.imgfmt)
>> +        if self.device_name is not None:
>> +            result = self.vm.qmp('blockdev-change-medium',
>> +                                 id=self.device_name, filename=new_img,
>> +                                 format=iotests.imgfmt)
>> +        else:
>> +            result = self.vm.qmp('blockdev-change-medium',
>> +                                 device='drive0', filename=new_img,
>> +                                 format=iotests.imgfmt)
>
> I'm not enough of a python guru to know if there is any way to compress
> this to a shorter format (I do know, however, that the lack of an
> obvious ?: operator in python can indeed result in verbose if/else
> clauses compared to other languages).

Actually there is a direct equivalent of "?:" (which unfortunately isn't
in C11) in Python: "or". So you can use:

        result = self.vm.qmp('blockdev-change-medium',
                             id=self.device_name or 'drive0', filename=new_img,
                             format=iotests.imgfmt)

Sascha
-- 
Softwareentwicklung Sascha Silbe, Niederhofenstraße 5/1, 71229 Leonberg
https://se-silbe.de/
USt-IdNr. DE281696641




reply via email to

[Prev in Thread] Current Thread [Next in Thread]