mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-25 18:33:44 +03:00
Convert warnings into errors on test
This commit is contained in:
parent
26952ecee4
commit
8baf6aa372
6
setup.py
6
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user