Opened 5 years ago

Closed 5 years ago

#16372 closed Bug (fixed)

TransactionTestCase doesn't count skipped cases in test result.

Reported by: Piotr Czachur Owned by: nobody
Component: Testing framework Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In r16369 return was added for test cases decorated with unittest.skip:

Index: django/trunk/django/test/testcases.py
===================================================================
--- a/django/trunk/django/test/testcases.py
+++ b/django/trunk/django/test/testcases.py
@@ -283,4 +283,9 @@
         include a call to super().setUp().
         """
+        testMethod = getattr(self, self._testMethodName)
+        if (getattr(self.__class__, "__unittest_skip__", False) or
+            getattr(testMethod, "__unittest_skip__", False)):
+            return

This should solve the problem:

self._addSkip(result, skip_why)

Cheers!

Attachments (1)

test-result-bugfix.diff (844 bytes) - added by Piotr Czachur 5 years ago.

Download all attachments as: .zip

Change History (5)

Changed 5 years ago by Piotr Czachur

Attachment: test-result-bugfix.diff added

comment:1 Changed 5 years ago by Piotr Czachur

Has patch: set

I've just attached patch. In fact, TransactionTestCase.call() for skipped tests is missing three method calls:

  • result.startTest(self)
  • self._addSkip(result, skip_why)
  • result.stopTest(self)

comment:2 Changed 5 years ago by Piotr Czachur

Needs tests: set

comment:3 Changed 5 years ago by Aymeric Augustin

Triage Stage: UnreviewedAccepted

comment:4 Changed 5 years ago by Ramiro Morales

Resolution: fixed
Status: newclosed

In [16579]:

Fixed #16372 -- Changed strategy implemented in r16369 to fix #14049 to avoid affecting the statistics of test cases ran/skipped kept by unittest. Thanks zimnyx for the report.

Note: See TracTickets for help on using tickets.
Back to Top