Changeset 607


Ignore:
Timestamp:
Nov 22, 2015, 3:11:47 PM (4 years ago)
Author:
cito
Message:

Skip over known libpq issue under Windows

Location:
trunk/module
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/module/TEST_PyGreSQL_classic_connection.py

    r605 r607  
    2020import threading
    2121import time
     22import os
    2223
    2324import pg  # the module under test
    2425
    2526from decimal import Decimal
    26 
    27 try:
    28     long
    29 except NameError:  # Python >= 3.0
    30     long = int
    31 
    32 unicode_strings = str is not bytes
    3327
    3428# We need a database to test against.  If LOCAL_PyGreSQL.py exists we will
     
    4337    pass
    4438
     39try:
     40    long
     41except NameError:  # Python >= 3.0
     42    long = int
     43
     44unicode_strings = str is not bytes
     45
     46windows = os.name == 'nt'
     47
     48# There is a known a bug in libpq under Windows which can cause
     49# the interface to crash when calling PQhost():
     50do_not_ask_for_host = windows
     51do_not_ask_for_host_reason = 'libpq issue on Windows'
     52
    4553
    4654def connect():
     
    7785            pass
    7886
     87    def is_method(self, attribute):
     88        """Check if given attribute on the connection is a method."""
     89        if do_not_ask_for_host and attribute == 'host':
     90            return False
     91        return callable(getattr(self.connection, attribute))
     92
    7993    def testClassName(self):
    8094        self.assertEqual(self.connection.__class__.__name__, 'Connection')
     
    94108        attributes = '''db error host options port
    95109            protocol_version server_version status tty user'''.split()
    96         connection = self.connection
    97         connection_attributes = [a for a in dir(connection)
    98             if not a.startswith('__')
    99             and not callable(getattr(connection, a))]
     110        connection_attributes = [a for a in dir(self.connection)
     111            if not a.startswith('__') and not self.is_method(a)]
    100112        self.assertEqual(attributes, connection_attributes)
    101113
     
    106118            inserttable locreate loimport parameter putline query reset
    107119            set_notice_receiver source transaction'''.split()
    108         connection = self.connection
    109         connection_methods = [a for a in dir(connection)
    110             if not a.startswith('__')
    111             and callable(getattr(connection, a))]
     120        connection_methods = [a for a in dir(self.connection)
     121            if not a.startswith('__') and self.is_method(a)]
    112122        self.assertEqual(methods, connection_methods)
    113123
     
    119129        self.assertTrue(not error or 'krb5_' in error)
    120130
     131    @unittest.skipIf(do_not_ask_for_host, do_not_ask_for_host_reason)
    121132    def testAttributeHost(self):
    122133        def_host = 'localhost'
  • trunk/module/TEST_PyGreSQL_classic_dbwrapper.py

    r602 r607  
    1616except ImportError:
    1717    import unittest
     18import os
    1819
    1920import pg  # the module under test
    2021
    2122from decimal import Decimal
    22 
    23 try:
    24     long
    25 except NameError:  # Python >= 3.0
    26     long = int
    2723
    2824# We need a database to test against.  If LOCAL_PyGreSQL.py exists we will
     
    3935except ImportError:
    4036    pass
     37
     38try:
     39    long
     40except NameError:  # Python >= 3.0
     41    long = int
     42
     43windows = os.name == 'nt'
     44
     45# There is a known a bug in libpq under Windows which can cause
     46# the interface to crash when calling PQhost():
     47do_not_ask_for_host = windows
     48do_not_ask_for_host_reason = 'libpq issue on Windows'
    4149
    4250
     
    136144        self.assertEqual(self.db.error, self.db.db.error)
    137145
     146    @unittest.skipIf(do_not_ask_for_host, do_not_ask_for_host_reason)
    138147    def testAttributeHost(self):
    139148        def_host = 'localhost'
Note: See TracChangeset for help on using the changeset viewer.