Change in vdsm[master]: testlib: Fix permutations of decorated tests

danken at redhat.com danken at redhat.com
Wed Jul 22 10:49:55 UTC 2015


Dan Kenigsberg has submitted this change and it was merged.

Change subject: testlib: Fix permutations of decorated tests
......................................................................


testlib: Fix permutations of decorated tests

Our expandPermutations infrastructure assume that generated tests use the
original test method, and break when using test decorators such as
@slowtestest or @stresstest.

The generated tests are registered incorrectly, overriding tests with the
same first permutation argument. Assuming we have the following test:

    @slowtest
    @permutations([[1, 2], [1, 4]])
    def test_permutations(self, a, b):
        ...

Instead of generating these tests:

    test_permutations(a=1, b=2)
    test_permutations(a=1, b=4)

We generate only one test, dropping the first permutation:

    test_permutations(kwargs=1)

This happens because decorated method signature is converted from:

    test_permutations(self, a, b)

To the generic form:

    test_permutations(*args, **kwargs)

When expanding permutations, we drop the first argument (args), assuming
it is self, and zipping the argument list with the rest of the argument
names (kwargs), dropping the second argument, and generating the wrong
argument string "kwargs=1".

The issue seems unfixable, since we need the original wrapped function
to get the original variables names, and we can have any number of
wrappers around it.

This patch fixes the issue in the same way nose and pytest handle this
issue, by generating positional argument string: "1, 2". This is not
nice as "a=1, b=2", but it works with decorated tests correctly.

So in the example above, we are generated these tests correctly:

    test_permutations(1, 2)
    test_permutations(1, 4)

Change-Id: I805885cb584f7ff015443682dd3bf52d0a44c74b
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
Reviewed-on: https://gerrit.ovirt.org/43433
Continuous-Integration: Jenkins CI
Reviewed-by: Piotr Kliczewski <piotr.kliczewski at gmail.com>
Reviewed-by: Francesco Romani <fromani at redhat.com>
Reviewed-by: Dan Kenigsberg <danken at redhat.com>
---
M tests/testlib.py
1 file changed, 2 insertions(+), 9 deletions(-)

Approvals:
  Piotr Kliczewski: Looks good to me, but someone else must approve
  Nir Soffer: Verified
  Jenkins CI: Passed CI tests
  Dan Kenigsberg: Looks good to me, approved
  Francesco Romani: Looks good to me, but someone else must approve



-- 
To view, visit https://gerrit.ovirt.org/43433
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I805885cb584f7ff015443682dd3bf52d0a44c74b
Gerrit-PatchSet: 2
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: Piotr Kliczewski <piotr.kliczewski at gmail.com>
Gerrit-Reviewer: automation at ovirt.org


More information about the vdsm-patches mailing list