Author: cito
Date: Thu Jan 7 17:00:27 2016
New Revision: 698
Log:
Skip over known libpq issue under Windows
Modified:
branches/4.x/module/tests/test_classic_connection.py
branches/4.x/module/tests/test_classic_dbwrapper.py
Modified: branches/4.x/module/tests/test_classic_connection.py
==============================================================================
--- branches/4.x/module/tests/test_classic_connection.py Thu Jan 7
11:59:10 2016 (r697)
+++ branches/4.x/module/tests/test_classic_connection.py Thu Jan 7
17:00:27 2016 (r698)
@@ -19,6 +19,7 @@
import tempfile
import threading
import time
+import os
import pg # the module under test
@@ -39,6 +40,13 @@
except ImportError:
pass
+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."""
@@ -73,11 +81,17 @@
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 testAllConnectAttributes(self):
attributes = '''db error host options port
protocol_version server_version status tty user'''.split()
connection_attributes = [a for a in dir(self.connection)
- if not callable(eval("self.connection." + a))]
+ if not a.startswith('__') and not self.is_method(a)]
self.assertEqual(attributes, connection_attributes)
def testAllConnectMethods(self):
@@ -90,7 +104,7 @@
methods.remove('escape_identifier')
methods.remove('escape_literal')
connection_methods = [a for a in dir(self.connection)
- if callable(eval("self.connection." + a))]
+ if not a.startswith('__') and self.is_method(a)]
self.assertEqual(methods, connection_methods)
def testAttributeDb(self):
@@ -100,6 +114,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: branches/4.x/module/tests/test_classic_dbwrapper.py
==============================================================================
--- branches/4.x/module/tests/test_classic_dbwrapper.py Thu Jan 7 11:59:10
2016 (r697)
+++ branches/4.x/module/tests/test_classic_dbwrapper.py Thu Jan 7 17:00:27
2016 (r698)
@@ -15,6 +15,7 @@
import unittest2 as unittest # for Python < 2.7
except ImportError:
import unittest
+import os
import sys
@@ -39,6 +40,13 @@
except ImportError:
pass
+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."""
@@ -138,6 +146,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