Skip test_cleanup_on_badconn_close on Windows

The Windows server version of PostgreSQL uses a function called pgkill in the
file kill.c in place of the UNIX kill function.  This pgkill function
simulates some of the SIGHUP like commands by passing signals through a named
pipe.  Because it is passing the signal through a pipe, the server doesn't get
the kill signal immediately and therefore fails the test on
test_connection.ConnectionTests.test_cleanup_on_badconn_close.
Ideally, the test should check to see if the server is running on Windows, not
the psycopg.
This commit is contained in:
Jason Erickson 2014-05-12 16:12:50 -06:00 committed by Daniele Varrazzo
parent c5f2e29dde
commit 8746b0c6b7
2 changed files with 14 additions and 0 deletions

View File

@ -34,6 +34,7 @@ import psycopg2.extensions
from testutils import unittest, decorate_all_tests, skip_if_no_superuser from testutils import unittest, decorate_all_tests, skip_if_no_superuser
from testutils import skip_before_postgres, skip_after_postgres from testutils import skip_before_postgres, skip_after_postgres
from testutils import ConnectingTestCase, skip_if_tpc_disabled from testutils import ConnectingTestCase, skip_if_tpc_disabled
from testutils import skip_if_windows
from testconfig import dsn, dbname from testconfig import dsn, dbname
@ -64,6 +65,7 @@ class ConnectionTests(ConnectingTestCase):
@skip_before_postgres(8, 4) @skip_before_postgres(8, 4)
@skip_if_no_superuser @skip_if_no_superuser
@skip_if_windows
def test_cleanup_on_badconn_close(self): def test_cleanup_on_badconn_close(self):
# ticket #148 # ticket #148
conn = self.conn conn = self.conn

View File

@ -25,6 +25,7 @@
# Use unittest2 if available. Otherwise mock a skip facility with warnings. # Use unittest2 if available. Otherwise mock a skip facility with warnings.
import os import os
import platform
import sys import sys
from functools import wraps from functools import wraps
from testconfig import dsn from testconfig import dsn
@ -302,6 +303,17 @@ def skip_if_no_getrefcount(f):
return f(self) return f(self)
return skip_if_no_getrefcount_ return skip_if_no_getrefcount_
def skip_if_windows(f):
"""Skip a test if run on windows"""
@wraps(f)
def skip_if_windows_(self):
if platform.system() == 'Windows':
return self.skipTest("Not supported on Windows")
else:
return f(self)
return skip_if_windows_
def script_to_py3(script): def script_to_py3(script):
"""Convert a script to Python3 syntax if required.""" """Convert a script to Python3 syntax if required."""
if sys.version_info[0] < 3: if sys.version_info[0] < 3: