diff options
author | Maurits van Rees <maurits@vanrees.org> | 2022-11-09 09:03:38 +0100 |
---|---|---|
committer | Maurits van Rees <maurits@vanrees.org> | 2022-11-09 09:03:38 +0100 |
commit | 51ed722fb9cc42b520481cd5046192a9fab7b31c (patch) | |
tree | a5f02ee9ab8c65f0bd8ac64aba1b2c4aaa91ad6f | |
parent | 191a935982424cba0118a5c643295c205d644c88 (diff) | |
download | zope-exceptions-51ed722fb9cc42b520481cd5046192a9fab7b31c.tar.gz |
Moved imports from test to top of file.
-rw-r--r-- | src/zope/exceptions/tests/test_exceptionformatter.py | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/zope/exceptions/tests/test_exceptionformatter.py b/src/zope/exceptions/tests/test_exceptionformatter.py index 0ec0c2a..cedfc5d 100644 --- a/src/zope/exceptions/tests/test_exceptionformatter.py +++ b/src/zope/exceptions/tests/test_exceptionformatter.py @@ -17,6 +17,13 @@ import sys import unittest +try: + from urllib.error import HTTPError +except ImportError: + # BBB for Python 2.7 + from urllib2 import HTTPError + + IS_PY39_OR_GREATER = sys.version_info >= (3, 9) @@ -286,11 +293,6 @@ class TextExceptionFormatterTests(unittest.TestCase): # https://github.com/plone/Products.CMFPlone/issues/3663 # We don't want to get an error when we format an error, # so let's compensate in our code. - try: - from urllib.error import HTTPError - except ImportError: - # BBB for Python 2.7 - from urllib2 import HTTPError fmt = self._makeOne() err = HTTPError('url', 400, 'oops', [], None) result = fmt.formatExceptionOnly(HTTPError, err).strip() @@ -304,11 +306,6 @@ class TextExceptionFormatterTests(unittest.TestCase): def test_formatException_httperror(self): # See test_formatExceptionOnly_httperror. # Here we check that formatException works. - try: - from urllib.error import HTTPError - except ImportError: - # BBB for Python 2.7 - from urllib2 import HTTPError fmt = self._makeOne() err = HTTPError('url', 400, 'oops', [], None) result = fmt.formatException(HTTPError, err, None) @@ -955,7 +952,7 @@ class DummyCode(object): # The 27 in the return value is chosen to match tb_recurse.tb_lineno=27 # in test_formatException_recursion_in_tb_stack in this file. # The rest is random. - # Note that this code is only called on Python 3.11, so we mark it for + # Note that this code is only called on Python 3.11+, so we mark it for # the coverage tool. return [(27, 2, 3, 4)] # pragma: no cover |