#14049 closed Cleanup/optimization (fixed)
Fixture loading should be skipped for TestCase decorated with @skip*
Reported by: | Piotr Czachur | Owned by: | Paul McMillan |
---|---|---|---|
Component: | Testing framework | Version: | 1.2 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
TransactionTestCase overrides unittest.TestCase.__call__() and always runs _fixture_setup(), even for skipped tests (decorated with @skip* from unittest).
It makes no sense at all and it's really waste of time to wait for those fixtures to load.
class TransactionTestCase(unittest.TestCase): def _pre_setup(self): """Performs any pre-test setup. This includes: * Flushing the database. * If the Test Case class has a 'fixtures' member, installing the named fixtures. * If the Test Case class has a 'urls' member, replace the ROOT_URLCONF with it. * Clearing the mail test outbox. """ self._fixture_setup() self._urlconf_setup() mail.outbox = [] # ... def __call__(self, result=None): """ Wrapper around default __call__ method to perform common Django test set up. This means that user-defined Test Cases aren't required to include a call to super().setUp(). """ self.client = Client() try: self._pre_setup() # LOAD FOR EVERY TestCase except (KeyboardInterrupt, SystemExit): raise except Exception: import sys result.addError(self, sys.exc_info()) return super(TransactionTestCase, self).__call__(result) # HERE @skip* decorators are honoured
Attachments (1)
Change History (10)
comment:1 by , 14 years ago
comment:2 by , 14 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 14 years ago
More broadly, the test running framework needs some cleanup in light of the changes to unittest, so this may get rolled into that.
comment:4 by , 14 years ago
Paul,
in fact I'm using unittest from 2.7 under Python 2.6 (I'm aware of existence unittest2, but unitest from 2.7 works just fine for me).
Cheers.
comment:5 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Cleanup/optimization |
by , 14 years ago
Attachment: | 14049.diff added |
---|
comment:6 by , 14 years ago
Easy pickings: | unset |
---|---|
Has patch: | set |
comment:7 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
In [16369]:
(The changeset message doesn't reference this ticket)
It's related to #12991