diff options
| author | Mads Jensen <mje@inducks.org> | 2017-03-09 16:17:41 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-06-28 14:07:55 -0400 |
| commit | 550cb3a365dee4edfdd1563224d5304de2a57fda (patch) | |
| tree | fb532f38774ff7619edd2a4532c3daae1ee0ac5a /tests/admin_scripts | |
| parent | 43a4835edf32c57eb74c0eb207c276734a34abcf (diff) | |
Fixed #27818 -- Replaced try/except/pass with contextlib.suppress().
Diffstat (limited to 'tests/admin_scripts')
| -rw-r--r-- | tests/admin_scripts/tests.py | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py index e2d2a3bca1..d90456ac13 100644 --- a/tests/admin_scripts/tests.py +++ b/tests/admin_scripts/tests.py @@ -12,6 +12,7 @@ import subprocess import sys import tempfile import unittest +from contextlib import suppress from io import StringIO from unittest import mock @@ -95,12 +96,10 @@ 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 - try: + with suppress(OSError): 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): @@ -166,10 +165,8 @@ class AdminScriptTestCase(unittest.TestCase): def run_manage(self, args, settings_file=None): def safe_remove(path): - try: + with suppress(OSError): 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') |
