avocado-framework / avocado

Avocado is a set of tools and libraries to help with automated testing. One can call it a test framework with benefits. Native tests are written in Python and they follow the unittest pattern, but any executable can serve as a test.
https://avocado-framework.github.io/
Other
345 stars 343 forks source link

Class dependencies are used only on first test #6068

Open richtja opened 1 day ago

richtja commented 1 day ago

Describe the bug If we declare dependencies for test class, avocado will fulfil the dependency only for the first test and others are skipped.

Steps to reproduce

from avocado import Test

class PassTest(Test):
    """
    Example test that passes.

    :avocado: dependency={"type": "package", "name": "hello"}
    """

    def test(self):
        """
        A test simply doesn't have to fail in order to pass
        """

    def testi_1(self):
        """
        A test simply doesn't have to fail in order to pass
        """

Expected behavior

$ avocado run examples/tests/passtest_with_dependency.py
JOB ID     : 5277ab385cf56d90fd7c527cb8da66a6e55681da
JOB LOG    : /home/janrichter/avocado/job-results/job-2024-11-20T11.09-5277ab3/job.log
 (2/2) examples/tests/passtest_with_dependency.py:PassTest.testi_1: STARTED
 (2/2) examples/tests/passtest_with_dependency.py:PassTest.testi_1: PASS
 (1/2) examples/tests/passtest_with_dependency.py:PassTest.test: STARTED
 (1/2) examples/tests/passtest_with_dependency.py:PassTest.test: PASS
RESULTS    : PASS 0 | ERROR 0 | FAIL 0 | SKIP 2 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB HTML   : /home/janrichter/avocado/job-results/job-2024-11-20T11.09-5277ab3/results.html
JOB TIME   : 3.82 s

Current behavior

$ avocado run examples/tests/passtest_with_dependency.py
JOB ID     : 5277ab385cf56d90fd7c527cb8da66a6e55681da
JOB LOG    : /home/janrichter/avocado/job-results/job-2024-11-20T11.09-5277ab3/job.log
 (2/2) examples/tests/passtest_with_dependency.py:PassTest.testi_1: STARTED
 (2/2) examples/tests/passtest_with_dependency.py:PassTest.testi_1: SKIP: Dependency was not fulfilled.
 (1/2) examples/tests/passtest_with_dependency.py:PassTest.test: STARTED
 (1/2) examples/tests/passtest_with_dependency.py:PassTest.test: SKIP: PASS
RESULTS    : PASS 0 | ERROR 0 | FAIL 0 | SKIP 2 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB HTML   : /home/janrichter/avocado/job-results/job-2024-11-20T11.09-5277ab3/results.html
JOB TIME   : 3.82 s