summaryrefslogtreecommitdiff
path: root/tests/admin_scripts/tests.py
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 /tests/admin_scripts/tests.py
parent8b2515a450ef376b9205029090af0a79c8341bd7 (diff)
Reverted "Fixed #27818 -- Replaced try/except/pass with contextlib.suppress()."
This reverts commit 550cb3a365dee4edfdd1563224d5304de2a57fda because try/except performs better.
Diffstat (limited to 'tests/admin_scripts/tests.py')
-rw-r--r--tests/admin_scripts/tests.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py
index b8bcea35f0..096984032f 100644
--- a/tests/admin_scripts/tests.py
+++ b/tests/admin_scripts/tests.py
@@ -12,7 +12,6 @@ import subprocess
import sys
import tempfile
import unittest
-from contextlib import suppress
from io import StringIO
from unittest import mock
@@ -96,10 +95,12 @@ class AdminScriptTestCase(unittest.TestCase):
# Also try to remove the compiled file; if it exists, it could
# mess up later tests that depend upon the .py file not existing
- with suppress(OSError):
+ try:
if sys.platform.startswith('java'):
# Jython produces module$py.class files
os.remove(re.sub(r'\.py$', '$py.class', full_name))
+ except OSError:
+ pass
# Also remove a __pycache__ directory, if it exists
cache_name = os.path.join(self.test_dir, '__pycache__')
if os.path.isdir(cache_name):
@@ -165,8 +166,10 @@ class AdminScriptTestCase(unittest.TestCase):
def run_manage(self, args, settings_file=None):
def safe_remove(path):
- with suppress(OSError):
+ try:
os.remove(path)
+ except OSError:
+ pass
conf_dir = os.path.dirname(conf.__file__)
template_manage_py = os.path.join(conf_dir, 'project_template', 'manage.py-tpl')