mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-17 01:20:32 +03:00
Remove redundant hasattr checks
This commit is contained in:
parent
ffcc65d4f0
commit
53c1c5dcc1
3
setup.py
3
setup.py
|
@ -214,8 +214,7 @@ or with the pg_config option in 'setup.cfg'.
|
||||||
|
|
||||||
# Support unicode paths, if this version of Python provides the
|
# Support unicode paths, if this version of Python provides the
|
||||||
# necessary infrastructure:
|
# necessary infrastructure:
|
||||||
if sys.version_info[0] < 3 \
|
if sys.version_info[0] < 3:
|
||||||
and hasattr(sys, 'getfilesystemencoding'):
|
|
||||||
pg_config_path = pg_config_path.encode(
|
pg_config_path = pg_config_path.encode(
|
||||||
sys.getfilesystemencoding())
|
sys.getfilesystemencoding())
|
||||||
|
|
||||||
|
|
|
@ -32,37 +32,8 @@ from functools import wraps
|
||||||
from testconfig import dsn, repl_dsn
|
from testconfig import dsn, repl_dsn
|
||||||
|
|
||||||
|
|
||||||
if hasattr(unittest, 'skipIf'):
|
skip = unittest.skip
|
||||||
skip = unittest.skip
|
skipIf = unittest.skipIf
|
||||||
skipIf = unittest.skipIf
|
|
||||||
|
|
||||||
else:
|
|
||||||
import warnings
|
|
||||||
|
|
||||||
def skipIf(cond, msg):
|
|
||||||
def skipIf_(f):
|
|
||||||
@wraps(f)
|
|
||||||
def skipIf__(self):
|
|
||||||
if cond:
|
|
||||||
with warnings.catch_warnings():
|
|
||||||
warnings.simplefilter('always', UserWarning)
|
|
||||||
warnings.warn(msg)
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
return f(self)
|
|
||||||
return skipIf__
|
|
||||||
return skipIf_
|
|
||||||
|
|
||||||
def skip(msg):
|
|
||||||
return skipIf(True, msg)
|
|
||||||
|
|
||||||
def skipTest(self, msg):
|
|
||||||
with warnings.catch_warnings():
|
|
||||||
warnings.simplefilter('always', UserWarning)
|
|
||||||
warnings.warn(msg)
|
|
||||||
return
|
|
||||||
|
|
||||||
unittest.TestCase.skipTest = skipTest
|
|
||||||
|
|
||||||
# Silence warnings caused by the stubbornness of the Python unittest
|
# Silence warnings caused by the stubbornness of the Python unittest
|
||||||
# maintainers
|
# maintainers
|
||||||
|
|
Loading…
Reference in New Issue
Block a user