summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2017-02-02 19:03:22 +0000
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2017-02-03 04:41:32 +0000
commit8baf6aa37293c75e8ffbf150f6504faa43a08045 (patch)
tree7ca5f2c635c5bb12de308f538d844392a71e1a43
parent26952ecee421350fd234f9390f03285a966b0d46 (diff)
downloadpsycopg2-8baf6aa37293c75e8ffbf150f6504faa43a08045.tar.gz
Convert warnings into errors on test
-rw-r--r--setup.py6
-rwxr-xr-xtests/__init__.py5
-rwxr-xr-xtests/test_errcodes.py5
-rwxr-xr-xtests/test_types_extras.py11
-rw-r--r--tests/testutils.py8
5 files changed, 29 insertions, 6 deletions
diff --git a/setup.py b/setup.py
index 1c5c859..d251f98 100644
--- a/setup.py
+++ b/setup.py
@@ -50,7 +50,11 @@ else:
# workaround subclass for ticket #153
pass
- sys.path.insert(0, 'scripts')
+ # Configure distutils to run our custom 2to3 fixers as well
+ from lib2to3.refactor import get_fixers_from_package
+ build_py.fixer_names = [f for f in get_fixers_from_package('lib2to3.fixes')
+ # creates a pending deprecation warning on py 3.4
+ if not f.endswith('.fix_reload')]
try:
import configparser
diff --git a/tests/__init__.py b/tests/__init__.py
index 1a24099..5382afe 100755
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -22,6 +22,11 @@
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
# License for more details.
+# Convert warnings into errors here. We can't do it with -W because on
+# Travis importing site raises a warning.
+import warnings
+warnings.simplefilter('error') # noqa
+
import sys
from testconfig import dsn
from testutils import unittest
diff --git a/tests/test_errcodes.py b/tests/test_errcodes.py
index 6865194..3e7ed81 100755
--- a/tests/test_errcodes.py
+++ b/tests/test_errcodes.py
@@ -27,7 +27,10 @@ from testutils import unittest, ConnectingTestCase
try:
reload
except NameError:
- from imp import reload
+ try:
+ from importlib import reload
+ except ImportError:
+ from imp import reload
from threading import Thread
from psycopg2 import errorcodes
diff --git a/tests/test_types_extras.py b/tests/test_types_extras.py
index 8e61561..7249ae0 100755
--- a/tests/test_types_extras.py
+++ b/tests/test_types_extras.py
@@ -17,6 +17,7 @@ from __future__ import with_statement
import re
import sys
+import warnings
from decimal import Decimal
from datetime import date, datetime
from functools import wraps
@@ -77,7 +78,10 @@ class TypesExtrasTests(ConnectingTestCase):
self.failUnless(type(s) == list and len(s) == 0)
def testINET(self):
- psycopg2.extras.register_inet()
+ with warnings.catch_warnings():
+ warnings.simplefilter('ignore', DeprecationWarning)
+ psycopg2.extras.register_inet()
+
i = psycopg2.extras.Inet("192.168.1.0/24")
s = self.execute("SELECT %s AS foo", (i,))
self.failUnless(i.addr == s.addr)
@@ -86,7 +90,10 @@ class TypesExtrasTests(ConnectingTestCase):
self.failUnless(s is None)
def testINETARRAY(self):
- psycopg2.extras.register_inet()
+ with warnings.catch_warnings():
+ warnings.simplefilter('ignore', DeprecationWarning)
+ psycopg2.extras.register_inet()
+
i = psycopg2.extras.Inet("192.168.1.0/24")
s = self.execute("SELECT %s AS foo", ([i],))
self.failUnless(i.addr == s[0].addr)
diff --git a/tests/testutils.py b/tests/testutils.py
index 9347735..d63dc00 100644
--- a/tests/testutils.py
+++ b/tests/testutils.py
@@ -50,7 +50,9 @@ else:
@wraps(f)
def skipIf__(self):
if cond:
- warnings.warn(msg)
+ with warnings.catch_warnings():
+ warnings.simplefilter('always', UserWarning)
+ warnings.warn(msg)
return
else:
return f(self)
@@ -61,7 +63,9 @@ else:
return skipIf(True, msg)
def skipTest(self, msg):
- warnings.warn(msg)
+ with warnings.catch_warnings():
+ warnings.simplefilter('always', UserWarning)
+ warnings.warn(msg)
return
unittest.TestCase.skipTest = skipTest