From 8746b0c6b7a243f97fa2d769c6cbf4b48a523ab3 Mon Sep 17 00:00:00 2001 From: Jason Erickson Date: Mon, 12 May 2014 16:12:50 -0600 Subject: [PATCH] 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. --- tests/test_connection.py | 2 ++ tests/testutils.py | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/tests/test_connection.py b/tests/test_connection.py index 21f7a499..65074048 100755 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -34,6 +34,7 @@ import psycopg2.extensions from testutils import unittest, decorate_all_tests, skip_if_no_superuser from testutils import skip_before_postgres, skip_after_postgres from testutils import ConnectingTestCase, skip_if_tpc_disabled +from testutils import skip_if_windows from testconfig import dsn, dbname @@ -64,6 +65,7 @@ class ConnectionTests(ConnectingTestCase): @skip_before_postgres(8, 4) @skip_if_no_superuser + @skip_if_windows def test_cleanup_on_badconn_close(self): # ticket #148 conn = self.conn diff --git a/tests/testutils.py b/tests/testutils.py index 0569edef..12732ac6 100644 --- a/tests/testutils.py +++ b/tests/testutils.py @@ -25,6 +25,7 @@ # Use unittest2 if available. Otherwise mock a skip facility with warnings. import os +import platform import sys from functools import wraps from testconfig import dsn @@ -302,6 +303,17 @@ def skip_if_no_getrefcount(f): return f(self) 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): """Convert a script to Python3 syntax if required.""" if sys.version_info[0] < 3: