summaryrefslogtreecommitdiff
path: root/tests/testutils.py
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2019-03-16 08:30:15 -0700
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2019-03-16 18:03:41 +0000
commitd90ad8627d0a7244abeee7cd3a9418d529dc1428 (patch)
tree40f19d7f4204546ba44c61d6e9f0f17529ea9aa5 /tests/testutils.py
parent194efc4375d5a8f821a3f3d5840f03d7a3d668e4 (diff)
downloadpsycopg2-d90ad8627d0a7244abeee7cd3a9418d529dc1428.tar.gz
Move imports to the top of the module across tests
Allows removing many duplicate imports and better follows PEP8 guidelines: https://www.python.org/dev/peps/pep-0008/#imports > Imports are always put at the top of the file, just after any module > comments and docstrings, and before module globals and constants.
Diffstat (limited to 'tests/testutils.py')
-rw-r--r--tests/testutils.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/testutils.py b/tests/testutils.py
index 24e52f1..8dab1b6 100644
--- a/tests/testutils.py
+++ b/tests/testutils.py
@@ -33,8 +33,11 @@ import unittest
from functools import wraps
from ctypes.util import find_library
from .testconfig import dsn, repl_dsn
+from psycopg2 import ProgrammingError
from psycopg2.compat import text_type
+from .testconfig import green
+
# Python 2/3 compatibility
if sys.version_info[0] == 2:
@@ -241,7 +244,6 @@ def skip_if_tpc_disabled(f):
"""Skip a test if the server has tpc support disabled."""
@wraps(f)
def skip_if_tpc_disabled_(self):
- from psycopg2 import ProgrammingError
cnn = self.connect()
cur = cnn.cursor()
try:
@@ -368,7 +370,6 @@ def skip_if_no_superuser(f):
"""Skip a test if the database user running the test is not a superuser"""
@wraps(f)
def skip_if_no_superuser_(self):
- from psycopg2 import ProgrammingError
try:
return f(self)
except ProgrammingError as e:
@@ -383,7 +384,6 @@ def skip_if_no_superuser(f):
def skip_if_green(reason):
def skip_if_green_(cls):
- from .testconfig import green
decorator = unittest.skipIf(green, reason)
return decorator(cls)
return skip_if_green_