From: H Date: Thu, 10 Feb 2022 23:50:41 +0000 (+0000) Subject: Move Windows test to separate file to avoid applying the asyncio mark X-Git-Tag: pool-3.1.1~9^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6661a0c9a46d45f481265ec4fe3fdde0205c57ca;p=thirdparty%2Fpsycopg.git Move Windows test to separate file to avoid applying the asyncio mark --- diff --git a/tests/test_connection_async.py b/tests/test_connection_async.py index 2d471c7f9..804c7bcd2 100644 --- a/tests/test_connection_async.py +++ b/tests/test_connection_async.py @@ -1,14 +1,12 @@ import time import pytest -import asyncio import logging -import sys import weakref import psycopg from psycopg import AsyncConnection, Notify from psycopg.rows import tuple_row -from psycopg.errors import InterfaceError, UndefinedTable +from psycopg.errors import UndefinedTable from psycopg.conninfo import conninfo_to_dict, make_conninfo from .utils import gc_collect @@ -688,21 +686,3 @@ async def test_connect_context_copy(dsn, aconn): cur = await aconn2.execute("select %b", ["hello"]) assert (await cur.fetchone())[0] == "hellob" # type: ignore[index] await aconn2.close() - - -@pytest.mark.skipif(sys.platform != "win32", reason="windows only test") -def test_windows_error(dsn): - loop = asyncio.ProactorEventLoop() # type: ignore[attr-defined] - - async def go(): - with pytest.raises( - InterfaceError, - match="Psycopg cannot use the 'ProactorEventLoop'", - ): - await psycopg.AsyncConnection.connect(dsn) - - try: - loop.run_until_complete(go()) - finally: - loop.run_until_complete(loop.shutdown_asyncgens()) - loop.close() diff --git a/tests/test_windows.py b/tests/test_windows.py new file mode 100644 index 000000000..bb491cd16 --- /dev/null +++ b/tests/test_windows.py @@ -0,0 +1,24 @@ +import pytest +import asyncio +import sys + +import psycopg +from psycopg.errors import InterfaceError + + +@pytest.mark.skipif(sys.platform != "win32", reason="windows only test") +def test_windows_error(dsn): + loop = asyncio.ProactorEventLoop() # type: ignore[attr-defined] + + async def go(): + with pytest.raises( + InterfaceError, + match="Psycopg cannot use the 'ProactorEventLoop'", + ): + await psycopg.AsyncConnection.connect(dsn) + + try: + loop.run_until_complete(go()) + finally: + loop.run_until_complete(loop.shutdown_asyncgens()) + loop.close()