summaryrefslogtreecommitdiffstats
path: root/tests/test_windows.py
blob: 09e61ba93df5b4d0bf1f6f5019eb6985706ec609 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import pytest
import asyncio
import sys

from psycopg.errors import InterfaceError


@pytest.mark.skipif(sys.platform != "win32", reason="windows only test")
def test_windows_error(aconn_cls, dsn):
    loop = asyncio.ProactorEventLoop()  # type: ignore[attr-defined]

    async def go():
        with pytest.raises(
            InterfaceError,
            match="Psycopg cannot use the 'ProactorEventLoop'",
        ):
            await aconn_cls.connect(dsn)

    try:
        loop.run_until_complete(go())
    finally:
        loop.run_until_complete(loop.shutdown_asyncgens())
        loop.close()