mirror of
				https://github.com/psycopg/psycopg2.git
				synced 2025-11-04 17:57:30 +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,6 +27,9 @@ from testutils import unittest, ConnectingTestCase
 | 
				
			||||||
try:
 | 
					try:
 | 
				
			||||||
    reload
 | 
					    reload
 | 
				
			||||||
except NameError:
 | 
					except NameError:
 | 
				
			||||||
 | 
					    try:
 | 
				
			||||||
 | 
					        from importlib import reload
 | 
				
			||||||
 | 
					    except ImportError:
 | 
				
			||||||
        from imp import reload
 | 
					        from imp import reload
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from threading import Thread
 | 
					from threading import Thread
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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):
 | 
				
			||||||
 | 
					        with warnings.catch_warnings():
 | 
				
			||||||
 | 
					            warnings.simplefilter('ignore', DeprecationWarning)
 | 
				
			||||||
            psycopg2.extras.register_inet()
 | 
					            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):
 | 
				
			||||||
 | 
					        with warnings.catch_warnings():
 | 
				
			||||||
 | 
					            warnings.simplefilter('ignore', DeprecationWarning)
 | 
				
			||||||
            psycopg2.extras.register_inet()
 | 
					            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,6 +50,8 @@ else:
 | 
				
			||||||
            @wraps(f)
 | 
					            @wraps(f)
 | 
				
			||||||
            def skipIf__(self):
 | 
					            def skipIf__(self):
 | 
				
			||||||
                if cond:
 | 
					                if cond:
 | 
				
			||||||
 | 
					                    with warnings.catch_warnings():
 | 
				
			||||||
 | 
					                        warnings.simplefilter('always', UserWarning)
 | 
				
			||||||
                        warnings.warn(msg)
 | 
					                        warnings.warn(msg)
 | 
				
			||||||
                    return
 | 
					                    return
 | 
				
			||||||
                else:
 | 
					                else:
 | 
				
			||||||
| 
						 | 
					@ -61,6 +63,8 @@ else:
 | 
				
			||||||
        return skipIf(True, msg)
 | 
					        return skipIf(True, msg)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def skipTest(self, msg):
 | 
					    def skipTest(self, msg):
 | 
				
			||||||
 | 
					        with warnings.catch_warnings():
 | 
				
			||||||
 | 
					            warnings.simplefilter('always', UserWarning)
 | 
				
			||||||
            warnings.warn(msg)
 | 
					            warnings.warn(msg)
 | 
				
			||||||
        return
 | 
					        return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user