diff options
author | Kamil <Kamil.plucinski97@gmail.com> | 2018-08-17 22:30:27 +0200 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2018-08-17 16:30:27 -0400 |
commit | 3d4080f19c606865f8f76d30d91c49d989a7f76c (patch) | |
tree | a6ff194fc197f5c17370f81d87f51d9caaada7c4 /django/test/utils.py | |
parent | abd0ad7681422d7c40a5ed12cc3c9ffca6b88422 (diff) | |
download | django-3d4080f19c606865f8f76d30d91c49d989a7f76c.tar.gz |
Fixed #29024 -- Made TestContextDecorator call disable() if setUp() raises an exception.
Diffstat (limited to 'django/test/utils.py')
-rw-r--r-- | django/test/utils.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/django/test/utils.py b/django/test/utils.py index 825c6b6d3b..234f831cfe 100644 --- a/django/test/utils.py +++ b/django/test/utils.py @@ -347,7 +347,11 @@ class TestContextDecorator: context = self.enable() if self.attr_name: setattr(inner_self, self.attr_name, context) - decorated_setUp(inner_self) + try: + decorated_setUp(inner_self) + except Exception: + self.disable() + raise def tearDown(inner_self): decorated_tearDown(inner_self) |