Dear Eric, (replying only to the Python coding part, haven't looked at the patch itself)
Eric Blake <ebl...@redhat.com> 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