Porting basic suite to pytest

Hi All, I've been experimenting with porting basic suite from nose to pytest. The rationale behind my efforts were nose being deprecated since a long time [1] and the ability to use pytest's awesome fixtures. Turns out it's not really that hard - with two patches [2][3] I was able to lay the groundwork for non-distruptive and incremental process of porting the basic suite module by module. You can find the steps needed to port a certain module described in [2]. Please find the patches that do the actual porting in this topic [4]. One of the hurdles of using pytest vs nose is that the former executes the test functions in the order they appear in the module. This comes from the reasoning, that tests should be independent, which is not the case for OST. Reordering the test functions to match '_TEST_LIST' for '002_bootstrap' and '004_basic_sanity' modules would make a huge disruption, so I've decided to use a 'pytest-ordering' plugin that allows you to define the order with '@pytest.mark.run(order=)' decorators. In other modules, like '003_basic_networking' and '006_migrations', minor refactoring was done, since "test" functions like 'migrate_vm' were used more than once in the module [5][6]. I tried to keep the changes minimal though - my aim was to do the porting - refinements can be done later. The junitxml reports generated by pytest seem to work fine, example of pytest-based module failure can be seen here [7]. Please let me know what do you think. Regards, Marcin [1] https://nose.readthedocs.io/en/latest/#note-to-users [2] https://gerrit.ovirt.org/#/c/107395 [3] https://gerrit.ovirt.org/#/c/107396 [4] https://gerrit.ovirt.org/#/q/topic:basic-suite-on-pytest+(status:open+OR+sta...) [5] https://github.com/oVirt/ovirt-system-tests/blob/73ed33aa6fbd471eb92593972e4... [6] https://github.com/oVirt/ovirt-system-tests/blob/73ed33aa6fbd471eb92593972e4... [7] https://jenkins.ovirt.org/job/ovirt-system-tests_standard-check-patch/8224/

On Thu, Mar 5, 2020 at 3:18 PM Marcin Sobczyk <msobczyk@redhat.com> wrote:
Hi All,
I've been experimenting with porting basic suite from nose to pytest. The rationale behind my efforts were nose being deprecated since a long time [1] and the ability to use pytest's awesome fixtures.
Turns out it's not really that hard - with two patches [2][3] I was able to lay the groundwork for non-distruptive and incremental process of porting the basic suite module by module. You can find the steps needed to port a certain module described in [2]. Please find the patches that do the actual porting in this topic [4].
Awesome!
One of the hurdles of using pytest vs nose is that the former executes the test functions in the order they appear in the module. This comes from the reasoning, that tests should be independent, which is not the case for OST. Reordering the test functions to match '_TEST_LIST' for '002_bootstrap' and '004_basic_sanity' modules would make a huge disruption, so I've decided to use a 'pytest-ordering' plugin that allows you to define the order with '@pytest.mark.run(order=)' decorators.
Until we get rid of dependencies between tests, this sounds like a reasonable solution.

On Thu, 5 Mar 2020 at 23:09, Nir Soffer <nsoffer@redhat.com> wrote:
On Thu, Mar 5, 2020 at 3:18 PM Marcin Sobczyk <msobczyk@redhat.com> wrote:
Hi All,
I've been experimenting with porting basic suite from nose to pytest. The rationale behind my efforts were nose being deprecated since a long time [1] and the ability to use pytest's awesome fixtures.
Turns out it's not really that hard - with two patches [2][3] I was able to lay the groundwork for non-distruptive and incremental process of porting the basic suite module by module. You can find the steps needed to port a certain module described in [2]. Please find the patches that do the actual porting in this topic [4].
Awesome!
One of the hurdles of using pytest vs nose is that the former executes the test functions in the order they appear in the module. This comes from the reasoning, that tests should be independent, which is not the case for OST. Reordering the test functions to match '_TEST_LIST' for '002_bootstrap' and '004_basic_sanity' modules would make a huge disruption, so I've decided to use a 'pytest-ordering' plugin that allows you to define the order with '@pytest.mark.run(order=)' decorators.
Until we get rid of dependencies between tests, this sounds like a reasonable solution.
+1. Glad to see this progress and keep pushing forward.
_______________________________________________ Devel mailing list -- devel@ovirt.org To unsubscribe send an email to devel-leave@ovirt.org Privacy Statement: https://www.ovirt.org/privacy-policy.html oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/ List Archives: https://lists.ovirt.org/archives/list/devel@ovirt.org/message/MAU6DKOV3LB3Y2...
participants (3)
-
Doron Fediuck
-
Marcin Sobczyk
-
Nir Soffer