avocado-framework/avocado

ERROR in tearDown overwrites the test status

richtja opened this issue · 0 comments

Describe the bug
When avocado job is interrupted, the test status might be overwritten is something happens during tearDown.

Steps to reproduce
test.py:

import time

from avocado import Test


class SleepTest(Test):

    """
    This test sleeps for 1s by default

    :param sleep_length: Sleep duration
    """

    def test(self):
        """
        Sleep for length seconds.
        """
        sleep_length = float(self.params.get("sleep_length", default=5))
        self.log.debug("Sleeping for %.2f seconds", sleep_length)
        time.sleep(sleep_length)

    def tearDown(self):
        self.error("tearDown ERROR")

command:

avocado run --job-timeout=3 test.py

Expected behavior
A clear and concise description of what you expected to happen.

JOB ID     : 859fda4217b6609f5b3c5066d808f58460ed2b23
JOB LOG    : /home/janrichter/avocado/job-results/job-2023-11-15T15.50-859fda4/job.log
 (1/1) /tmp/test.py:SleepTest.test: STARTED
 (1/1) /tmp/test.py:SleepTest.test: INTERRUPTED: Test interrupted: Timeout reached (2.72 s)

RESULTS    : PASS 0 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 1 | CANCEL 0
JOB HTML   : /home/janrichter/avocado/job-results/job-2023-11-15T15.50-859fda4/results.html
JOB TIME   : 3.82 s

Current behavior

JOB ID     : 6e89e37a5c82c933a8ca07be79b9998681da5224
JOB LOG    : /home/janrichter/avocado/job-results/job-2023-11-15T15.46-6e89e37/job.log
 (1/1) /tmp/test.py:SleepTest.test: STARTED
 (1/1) /tmp/test.py:SleepTest.test: ERROR: tearDown ERROR (2.72 s)

RESULTS    : PASS 0 | ERROR 1 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB HTML   : /home/janrichter/avocado/job-results/job-2023-11-15T15.46-6e89e37/results.html
JOB TIME   : 3.96 s