[libvirt] [dbus PATCH] tests: fix test_connect

Pavel Hrdina posted 1 patch 5 years ago
Failed in applying to current master (apply log)
tests/libvirttest.py | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
[libvirt] [dbus PATCH] tests: fix test_connect
Posted by Pavel Hrdina 5 years ago
Calling fixtures directly was removed in pytest 4.0, we can change the
fixture to be a wrapper around the original function and use the
original fixture name.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 tests/libvirttest.py | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/tests/libvirttest.py b/tests/libvirttest.py
index 14baf5b..a442196 100644
--- a/tests/libvirttest.py
+++ b/tests/libvirttest.py
@@ -84,13 +84,7 @@ class BaseTestClass():
         interface_obj.Create(0)
         return path, interface_obj
 
-    @pytest.fixture
     def node_device_create(self):
-        """ Fixture to create dummy node device on the test driver
-
-        This fixture should be used in the setup of every test manipulating
-        with node devices.
-        """
         # We need a usable parent nodedev: possible candidates are
         # scsi_host2 (available since libvirt 3.1.0) and
         # test-scsi-host-vport (available until libvirt 3.0.0).
@@ -109,6 +103,15 @@ class BaseTestClass():
         path = self.connect.NodeDeviceCreateXML(xml, 0)
         return path
 
+    @pytest.fixture(name="node_device_create")
+    def fixture_node_device_create(self):
+        """ Fixture to create dummy node device on the test driver
+
+        This fixture should be used in the setup of every test manipulating
+        with node devices.
+        """
+        return self.node_device_create()
+
     @pytest.fixture
     def storage_volume_create(self):
         """ Fixture to create dummy storage volume on the test driver
-- 
2.20.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [dbus PATCH] tests: fix test_connect
Posted by Cole Robinson 5 years ago
On 4/15/19 11:25 AM, Pavel Hrdina wrote:
> Calling fixtures directly was removed in pytest 4.0, we can change the
> fixture to be a wrapper around the original function and use the
> original fixture name.
> 
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
>  tests/libvirttest.py | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/tests/libvirttest.py b/tests/libvirttest.py
> index 14baf5b..a442196 100644
> --- a/tests/libvirttest.py
> +++ b/tests/libvirttest.py
> @@ -84,13 +84,7 @@ class BaseTestClass():
>          interface_obj.Create(0)
>          return path, interface_obj
>  
> -    @pytest.fixture
>      def node_device_create(self):
> -        """ Fixture to create dummy node device on the test driver
> -
> -        This fixture should be used in the setup of every test manipulating
> -        with node devices.
> -        """
>          # We need a usable parent nodedev: possible candidates are
>          # scsi_host2 (available since libvirt 3.1.0) and
>          # test-scsi-host-vport (available until libvirt 3.0.0).
> @@ -109,6 +103,15 @@ class BaseTestClass():
>          path = self.connect.NodeDeviceCreateXML(xml, 0)
>          return path
>  
> +    @pytest.fixture(name="node_device_create")
> +    def fixture_node_device_create(self):
> +        """ Fixture to create dummy node device on the test driver
> +
> +        This fixture should be used in the setup of every test manipulating
> +        with node devices.
> +        """
> +        return self.node_device_create()
> +
>      @pytest.fixture
>      def storage_volume_create(self):
>          """ Fixture to create dummy storage volume on the test driver
> 

Maybe I misunderstand but doesn't this storage_volume_create case
follow same pattern?

- Cole

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [dbus PATCH] tests: fix test_connect
Posted by Ján Tomko 5 years ago
On Mon, Apr 15, 2019 at 02:15:28PM -0400, Cole Robinson wrote:
>On 4/15/19 11:25 AM, Pavel Hrdina wrote:
>> Calling fixtures directly was removed in pytest 4.0, we can change the
>> fixture to be a wrapper around the original function and use the
>> original fixture name.

Would be nice to call out the direct caller here:
test_connect_node_device_create_xml

>>
>> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
>> ---
>>  tests/libvirttest.py | 15 +++++++++------
>>  1 file changed, 9 insertions(+), 6 deletions(-)
>>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

>> diff --git a/tests/libvirttest.py b/tests/libvirttest.py
>> index 14baf5b..a442196 100644
>> --- a/tests/libvirttest.py
>> +++ b/tests/libvirttest.py
>> @@ -84,13 +84,7 @@ class BaseTestClass():
>>          interface_obj.Create(0)
>>          return path, interface_obj
>>
>> -    @pytest.fixture
>>      def node_device_create(self):
>> -        """ Fixture to create dummy node device on the test driver
>> -
>> -        This fixture should be used in the setup of every test manipulating
>> -        with node devices.
>> -        """
>>          # We need a usable parent nodedev: possible candidates are
>>          # scsi_host2 (available since libvirt 3.1.0) and
>>          # test-scsi-host-vport (available until libvirt 3.0.0).
>> @@ -109,6 +103,15 @@ class BaseTestClass():
>>          path = self.connect.NodeDeviceCreateXML(xml, 0)
>>          return path
>>
>> +    @pytest.fixture(name="node_device_create")
>> +    def fixture_node_device_create(self):
>> +        """ Fixture to create dummy node device on the test driver
>> +
>> +        This fixture should be used in the setup of every test manipulating
>> +        with node devices.
>> +        """
>> +        return self.node_device_create()
>> +
>>      @pytest.fixture
>>      def storage_volume_create(self):
>>          """ Fixture to create dummy storage volume on the test driver
>>
>
>Maybe I misunderstand but doesn't this storage_volume_create case
>follow same pattern?
>

There is neither a direct caller of storage_volume_create nor an
equivalent test_connect_storage_volume_create_xml test.
The difference would be that libvirt doesn't have an event on storage volume
creation.

Jano
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [dbus PATCH] tests: fix test_connect
Posted by Pavel Hrdina 5 years ago
On Tue, Apr 16, 2019 at 12:44:26AM +0200, Ján Tomko wrote:
> On Mon, Apr 15, 2019 at 02:15:28PM -0400, Cole Robinson wrote:
> > On 4/15/19 11:25 AM, Pavel Hrdina wrote:
> > > Calling fixtures directly was removed in pytest 4.0, we can change the
> > > fixture to be a wrapper around the original function and use the
> > > original fixture name.
> 
> Would be nice to call out the direct caller here:
> test_connect_node_device_create_xml

Will do before pushing.

> > > 
> > > Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> > > ---
> > >  tests/libvirttest.py | 15 +++++++++------
> > >  1 file changed, 9 insertions(+), 6 deletions(-)
> > > 
> 
> Reviewed-by: Ján Tomko <jtomko@redhat.com>
> 
> > > diff --git a/tests/libvirttest.py b/tests/libvirttest.py
> > > index 14baf5b..a442196 100644
> > > --- a/tests/libvirttest.py
> > > +++ b/tests/libvirttest.py
> > > @@ -84,13 +84,7 @@ class BaseTestClass():
> > >          interface_obj.Create(0)
> > >          return path, interface_obj
> > > 
> > > -    @pytest.fixture
> > >      def node_device_create(self):
> > > -        """ Fixture to create dummy node device on the test driver
> > > -
> > > -        This fixture should be used in the setup of every test manipulating
> > > -        with node devices.
> > > -        """
> > >          # We need a usable parent nodedev: possible candidates are
> > >          # scsi_host2 (available since libvirt 3.1.0) and
> > >          # test-scsi-host-vport (available until libvirt 3.0.0).
> > > @@ -109,6 +103,15 @@ class BaseTestClass():
> > >          path = self.connect.NodeDeviceCreateXML(xml, 0)
> > >          return path
> > > 
> > > +    @pytest.fixture(name="node_device_create")
> > > +    def fixture_node_device_create(self):
> > > +        """ Fixture to create dummy node device on the test driver
> > > +
> > > +        This fixture should be used in the setup of every test manipulating
> > > +        with node devices.
> > > +        """
> > > +        return self.node_device_create()
> > > +
> > >      @pytest.fixture
> > >      def storage_volume_create(self):
> > >          """ Fixture to create dummy storage volume on the test driver
> > > 
> > 
> > Maybe I misunderstand but doesn't this storage_volume_create case
> > follow same pattern?
> > 
> 
> There is neither a direct caller of storage_volume_create nor an
> equivalent test_connect_storage_volume_create_xml test.
> The difference would be that libvirt doesn't have an event on storage volume
> creation.

Correct, for now we don't have the same issue here so there is no need
for the wrapper.  If in the future we will have to call the function
directly the patch should rewrite the fixture to this pattern.

Thanks,

Pavel
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list