Received: from eggs.gnu.org ([2001:4830:134:3::10]:51241) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkZLF-00086w-CH for qemu-devel@nongnu.org; Thu, 15 Sep 2016 12:16:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bkZLC-0006Vu-4K for qemu-devel@nongnu.org; Thu, 15 Sep 2016 12:16:49 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:58640) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkZLB-0006VE-SM for qemu-devel@nongnu.org; Thu, 15 Sep 2016 12:16:46 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u8FGDXQw131491 for ; Thu, 15 Sep 2016 12:16:43 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 25fqts06h8-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 15 Sep 2016 12:16:43 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 15 Sep 2016 17:16:40 +0100 From: Sascha Silbe In-Reply-To: <32842c09-6dce-b68b-d95e-de3813099faa@redhat.com> References: <1471625435-6190-1-git-send-email-kwolf@redhat.com> <1471625435-6190-11-git-send-email-kwolf@redhat.com> <32842c09-6dce-b68b-d95e-de3813099faa@redhat.com> Date: Thu, 15 Sep 2016 18:16:37 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Message-Id: <87mvj9cf4q.fsf@oc4731375738.ibm.com> Subject: Re: [Qemu-devel] [PATCH 10/10] qemu-iotests/118: Test media change with qdev name List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , Kevin Wolf , qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, mreitz@redhat.com Dear Eric, (replying only to the Python coding part, haven't looked at the patch itself) Eric Blake 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', ne= w_img) >>=20=20 >> def test_blockdev_change_medium(self): >> - result =3D self.vm.qmp('blockdev-change-medium', device=3D'driv= e0', >> - filename=3Dnew_i= mg, >> - format=3Diotests= .imgfmt) >> + if self.device_name is not None: >> + result =3D self.vm.qmp('blockdev-change-medium', >> + id=3Dself.device_name, filename=3Dnew_= img, >> + format=3Diotests.imgfmt) >> + else: >> + result =3D self.vm.qmp('blockdev-change-medium', >> + device=3D'drive0', filename=3Dnew_img, >> + format=3Diotests.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 =3D self.vm.qmp('blockdev-change-medium', id=3Dself.device_name or 'drive0', filename=3D= new_img, format=3Diotests.imgfmt) Sascha --=20 Softwareentwicklung Sascha Silbe, Niederhofenstra=C3=9Fe 5/1, 71229 Leonberg https://se-silbe.de/ USt-IdNr. DE281696641