Author: cito
Date: Sun Nov 22 15:11:47 2015
New Revision: 607
Log:
Skip over known libpq issue under Windows
Modified:
trunk/module/TEST_PyGreSQL_classic_connection.py
trunk/module/TEST_PyGreSQL_classic_dbwrapper.py
Modified: trunk/module/TEST_PyGreSQL_classic_connection.py
==============================================================================
--- trunk/module/TEST_PyGreSQL_classic_connection.py Sun Nov 22 14:09:49
2015 (r606)
+++ trunk/module/TEST_PyGreSQL_classic_connection.py Sun Nov 22 15:11:47
2015 (r607)
@@ -19,18 +19,12 @@
import unittest
import threading
import time
+import os
import pg # the module under test
from decimal import Decimal
-try:
- long
-except NameError: # Python >= 3.0
- long = int
-
-unicode_strings = str is not bytes
-
# We need a database to test against. If LOCAL_PyGreSQL.py exists we will
# get our information from that. Otherwise we use the defaults.
dbname = 'unittest'
@@ -42,6 +36,20 @@
except ImportError:
pass
+try:
+ long
+except NameError: # Python >= 3.0
+ long = int
+
+unicode_strings = str is not bytes
+
+windows = os.name == 'nt'
+
+# There is a known a bug in libpq under Windows which can cause
+# the interface to crash when calling PQhost():
+do_not_ask_for_host = windows
+do_not_ask_for_host_reason = 'libpq issue on Windows'
+
def connect():
"""Create a basic pg connection to the test database."""
@@ -76,6 +84,12 @@
except pg.InternalError:
pass
+ def is_method(self, attribute):
+ """Check if given attribute on the connection is a method."""
+ if do_not_ask_for_host and attribute == 'host':
+ return False
+ return callable(getattr(self.connection, attribute))
+
def testClassName(self):
self.assertEqual(self.connection.__class__.__name__, 'Connection')
@@ -93,10 +107,8 @@
def testAllConnectAttributes(self):
attributes = '''db error host options port
protocol_version server_version status tty user'''.split()
- connection = self.connection
- connection_attributes = [a for a in dir(connection)
- if not a.startswith('__')
- and not callable(getattr(connection, a))]
+ connection_attributes = [a for a in dir(self.connection)
+ if not a.startswith('__') and not self.is_method(a)]
self.assertEqual(attributes, connection_attributes)
def testAllConnectMethods(self):
@@ -105,10 +117,8 @@
fileno get_notice_receiver getline getlo getnotify
inserttable locreate loimport parameter putline query reset
set_notice_receiver source transaction'''.split()
- connection = self.connection
- connection_methods = [a for a in dir(connection)
- if not a.startswith('__')
- and callable(getattr(connection, a))]
+ connection_methods = [a for a in dir(self.connection)
+ if not a.startswith('__') and self.is_method(a)]
self.assertEqual(methods, connection_methods)
def testAttributeDb(self):
@@ -118,6 +128,7 @@
error = self.connection.error
self.assertTrue(not error or 'krb5_' in error)
+ @unittest.skipIf(do_not_ask_for_host, do_not_ask_for_host_reason)
def testAttributeHost(self):
def_host = 'localhost'
self.assertIsInstance(self.connection.host, str)
Modified: trunk/module/TEST_PyGreSQL_classic_dbwrapper.py
==============================================================================
--- trunk/module/TEST_PyGreSQL_classic_dbwrapper.py Sun Nov 22 14:09:49
2015 (r606)
+++ trunk/module/TEST_PyGreSQL_classic_dbwrapper.py Sun Nov 22 15:11:47
2015 (r607)
@@ -15,16 +15,12 @@
import unittest2 as unittest # for Python < 2.7
except ImportError:
import unittest
+import os
import pg # the module under test
from decimal import Decimal
-try:
- long
-except NameError: # Python >= 3.0
- long = int
-
# We need a database to test against. If LOCAL_PyGreSQL.py exists we will
# get our information from that. Otherwise we use the defaults.
# The current user must have create schema privilege on the database.
@@ -39,6 +35,18 @@
except ImportError:
pass
+try:
+ long
+except NameError: # Python >= 3.0
+ long = int
+
+windows = os.name == 'nt'
+
+# There is a known a bug in libpq under Windows which can cause
+# the interface to crash when calling PQhost():
+do_not_ask_for_host = windows
+do_not_ask_for_host_reason = 'libpq issue on Windows'
+
def DB():
"""Create a DB wrapper object connecting to the test database."""
@@ -135,6 +143,7 @@
self.assertTrue(not error or 'krb5_' in error)
self.assertEqual(self.db.error, self.db.db.error)
+ @unittest.skipIf(do_not_ask_for_host, do_not_ask_for_host_reason)
def testAttributeHost(self):
def_host = 'localhost'
host = self.db.host
_______________________________________________
PyGreSQL mailing list
[email protected]
https://mail.vex.net/mailman/listinfo.cgi/pygresql