From: Daniel Fortunov Date: Thu, 26 Nov 2020 08:33:53 +0000 (+0000) Subject: Windows compatibility for tests X-Git-Tag: 3.0.dev0~303 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6dbb7a6f67957b9d8c548f3f0e8a751b94ba91d8;p=thirdparty%2Fpsycopg.git Windows compatibility for tests * Skip test_connect_timeout() on Windows for the time being as Connection.connect() hangs for some reason. This skip can probably go away once connection timeouts are implemented. * test_multiprocess_close(): Turn LocalPath instance back into a str before putting it back into env["PYTHONPATH"] to avoid failure in: _winapi.CreateProcess(): TypeError: environment can only contain str --- diff --git a/tests/test_concurrency.py b/tests/test_concurrency.py index 2fc88c317..8dde58286 100644 --- a/tests/test_concurrency.py +++ b/tests/test_concurrency.py @@ -94,7 +94,7 @@ t.join() with (tmpdir / "mptest.py").open("w") as f: f.write(module) env = dict(os.environ) - env["PYTHONPATH"] = tmpdir + os.pathsep + env.get("PYTHONPATH", "") + env["PYTHONPATH"] = str(tmpdir + os.pathsep + env.get("PYTHONPATH", "")) # TODO: debug this. Importing c module fails on travis in this scenario env.pop("PSYCOPG3_IMPL", None) out = sp.check_output( diff --git a/tests/test_connection.py b/tests/test_connection.py index 24efbf50b..91f84a411 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -1,4 +1,5 @@ import gc +import sys import time import socket import pytest @@ -35,9 +36,10 @@ def test_connect_bad(): @pytest.mark.slow @pytest.mark.xfail +@pytest.mark.skipif(sys.platform == "win32", reason="connect() hangs on Win32") def test_connect_timeout(): s = socket.socket(socket.AF_INET) - s.bind(("", 0)) + s.bind(("localhost", 0)) port = s.getsockname()[1] s.listen(0)