summaryrefslogtreecommitdiff
path: root/django/test
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2017-09-07 08:16:21 -0400
committerGitHub <noreply@github.com>2017-09-07 08:16:21 -0400
commit6e4c6281dbb7ee12bcdc22620894edb4e9cf623f (patch)
tree1c21218d4b6f00c499f18943d5190ebe7b5248c9 /django/test
parent8b2515a450ef376b9205029090af0a79c8341bd7 (diff)
Reverted "Fixed #27818 -- Replaced try/except/pass with contextlib.suppress()."
This reverts commit 550cb3a365dee4edfdd1563224d5304de2a57fda because try/except performs better.
Diffstat (limited to 'django/test')
-rw-r--r--django/test/signals.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/django/test/signals.py b/django/test/signals.py
index 3507c69add..a623e756ce 100644
--- a/django/test/signals.py
+++ b/django/test/signals.py
@@ -2,7 +2,6 @@ import os
import threading
import time
import warnings
-from contextlib import suppress
from django.apps import apps
from django.core.exceptions import ImproperlyConfigured
@@ -64,10 +63,14 @@ def update_connections_time_zone(**kwargs):
# Reset the database connections' time zone
if kwargs['setting'] in {'TIME_ZONE', 'USE_TZ'}:
for conn in connections.all():
- with suppress(AttributeError):
+ try:
del conn.timezone
- with suppress(AttributeError):
+ except AttributeError:
+ pass
+ try:
del conn.timezone_name
+ except AttributeError:
+ pass
conn.ensure_timezone()
@@ -86,8 +89,10 @@ def reset_template_engines(**kwargs):
'INSTALLED_APPS',
}:
from django.template import engines
- with suppress(AttributeError):
+ try:
del engines.templates
+ except AttributeError:
+ pass
engines._templates = None
engines._engines = {}
from django.template.engine import Engine