mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-13 04:26:33 +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
|
# workaround subclass for ticket #153
|
||||||
pass
|
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:
|
try:
|
||||||
import configparser
|
import configparser
|
||||||
|
|
|
@ -22,6 +22,11 @@
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
# License for more details.
|
# 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
|
import sys
|
||||||
from testconfig import dsn
|
from testconfig import dsn
|
||||||
from testutils import unittest
|
from testutils import unittest
|
||||||
|
|
|
@ -27,7 +27,10 @@ from testutils import unittest, ConnectingTestCase
|
||||||
try:
|
try:
|
||||||
reload
|
reload
|
||||||
except NameError:
|
except NameError:
|
||||||
from imp import reload
|
try:
|
||||||
|
from importlib import reload
|
||||||
|
except ImportError:
|
||||||
|
from imp import reload
|
||||||
|
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from psycopg2 import errorcodes
|
from psycopg2 import errorcodes
|
||||||
|
|
|
@ -17,6 +17,7 @@ from __future__ import with_statement
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
import warnings
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
@ -77,7 +78,10 @@ class TypesExtrasTests(ConnectingTestCase):
|
||||||
self.failUnless(type(s) == list and len(s) == 0)
|
self.failUnless(type(s) == list and len(s) == 0)
|
||||||
|
|
||||||
def testINET(self):
|
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")
|
i = psycopg2.extras.Inet("192.168.1.0/24")
|
||||||
s = self.execute("SELECT %s AS foo", (i,))
|
s = self.execute("SELECT %s AS foo", (i,))
|
||||||
self.failUnless(i.addr == s.addr)
|
self.failUnless(i.addr == s.addr)
|
||||||
|
@ -86,7 +90,10 @@ class TypesExtrasTests(ConnectingTestCase):
|
||||||
self.failUnless(s is None)
|
self.failUnless(s is None)
|
||||||
|
|
||||||
def testINETARRAY(self):
|
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")
|
i = psycopg2.extras.Inet("192.168.1.0/24")
|
||||||
s = self.execute("SELECT %s AS foo", ([i],))
|
s = self.execute("SELECT %s AS foo", ([i],))
|
||||||
self.failUnless(i.addr == s[0].addr)
|
self.failUnless(i.addr == s[0].addr)
|
||||||
|
|
|
@ -50,7 +50,9 @@ else:
|
||||||
@wraps(f)
|
@wraps(f)
|
||||||
def skipIf__(self):
|
def skipIf__(self):
|
||||||
if cond:
|
if cond:
|
||||||
warnings.warn(msg)
|
with warnings.catch_warnings():
|
||||||
|
warnings.simplefilter('always', UserWarning)
|
||||||
|
warnings.warn(msg)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
return f(self)
|
return f(self)
|
||||||
|
@ -61,7 +63,9 @@ else:
|
||||||
return skipIf(True, msg)
|
return skipIf(True, msg)
|
||||||
|
|
||||||
def skipTest(self, msg):
|
def skipTest(self, msg):
|
||||||
warnings.warn(msg)
|
with warnings.catch_warnings():
|
||||||
|
warnings.simplefilter('always', UserWarning)
|
||||||
|
warnings.warn(msg)
|
||||||
return
|
return
|
||||||
|
|
||||||
unittest.TestCase.skipTest = skipTest
|
unittest.TestCase.skipTest = skipTest
|
||||||
|
|
Loading…
Reference in New Issue
Block a user