Dne 24. 03. 20 v 22:18 Pushpalogan napsal(a): > Hello, > > We have a test class that has a setUp and tearDown where setUp does mounting > and tearDown does Unmounting. There are times when an unmounting of a > directory fails and throws exception and I was wondering what is the best way > to handle exceptions in tearDown and propagate that as an error so the test > results are recorded appropriately. Currently that exception is being ignored > by avocado and the test is marked as passed. Please let me know if you need > additional information. > > Thanks, > Logan. >
Hello Pushpalogan, that looks like a bug, can you please share the details about the exception that is being raised and the Avocado version you are using? I tried recent 2ca72aa8d2660655cf02a4639b4a1691cb15694f with: diff --git a/examples/tests/passtest.py b/examples/tests/passtest.py index b30acdef..27a70db2 100755 --- a/examples/tests/passtest.py +++ b/examples/tests/passtest.py @@ -11,6 +11,8 @@ class PassTest(Test): :avocado: tags=fast """ + def tearDown(self): + raise Exception("testing exception") def test(self): """ and it correctly reports a test error: avocado.test: INIT 1-examples/tests/passtest.py:PassTest.test avocado.test: PARAMS (key=timeout, path=*, default=None) => None avocado.test: Test metadata: avocado.test: filename: /home/medic/Work/Projekty/avocado/avocado/examples/tests/passtest.py avocado.test: teststmpdir: /var/tmp/avocado_tt9f9h2i avocado.test: workdir: /var/tmp/avocado_6l2ld5d7/avocado_job_81urykeg/1-examples_tests_passtest.py_PassTest.test (1/1) examples/tests/passtest.py:PassTest.test: avocado.test: START 1-examples/tests/passtest.py:PassTest.test avocado.test: DATA (filename=output.expected) => NOT FOUND (data sources: variant, test, file) avocado.test: avocado.test: Reproduced traceback from: /home/medic/Work/Projekty/avocado/avocado/avocado/core/test.py:891 avocado.test: Traceback (most recent call last): avocado.test: File "/home/medic/Work/Projekty/avocado/avocado/examples/tests/passtest.py", line 15, in tearDown avocado.test: raise Exception("testing exception") avocado.test: Exception: testing exception avocado.test: avocado.test: DATA (filename=output.expected) => NOT FOUND (data sources: variant, test, file) avocado.test: DATA (filename=stdout.expected) => NOT FOUND (data sources: variant, test, file) avocado.test: DATA (filename=stderr.expected) => NOT FOUND (data sources: variant, test, file) avocado.test: ERROR 1-examples/tests/passtest.py:PassTest.test -> TestSetupFail: testing exception avocado.test: ERROR: testing exception (0.03 s) avocado.test: Test results available in /home/medic/avocado/job-results/job-2020-03-27T09.45-ecb36b7 RESULTS : PASS 0 | ERROR 1 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0 JOB TIME : 0.13 s avocado.sysinfo: Not logging /sys/kernel/debug/sched_features (file does not exist) avocado.sysinfo: Not logging 'numactl --hardware show' (command 'numactl' was not found) avocado.sysinfo: Not logging /proc/pci (file does not exist) avocado.sysinfo: Not logging /proc/slabinfo (lack of permissions) JOB HTML : /home/medic/avocado/job-results/job-2020-03-27T09.45-ecb36b7/results.html Regards, Lukáš
signature.asc
Description: OpenPGP digital signature