From: Daniele Varrazzo Date: Sat, 14 Mar 2020 11:28:10 +0000 (+1300) Subject: Dropped pfefix from a couple of enums X-Git-Tag: 3.0.dev0~723 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7a07207d9af92065e1d6a5b8358167cb64ac60f0;p=thirdparty%2Fpsycopg.git Dropped pfefix from a couple of enums --- diff --git a/psycopg3/pq.py b/psycopg3/pq.py index 460da89f6..f0a5dc747 100644 --- a/psycopg3/pq.py +++ b/psycopg3/pq.py @@ -11,9 +11,9 @@ implementation-dependant but all the implementations share the same interface. from .pq_enums import ( ConnStatus, - PostgresPollingStatus, + PollingStatus, TransactionStatus, - PGPing, + Ping, ) from . import pq_ctypes as pq_module @@ -23,9 +23,9 @@ PQerror = pq_module.PQerror __all__ = ( "ConnStatus", - "PostgresPollingStatus", + "PollingStatus", "TransactionStatus", - "PGPing", + "Ping", "PGconn", "PQerror", ) diff --git a/psycopg3/pq_ctypes.py b/psycopg3/pq_ctypes.py index 2675b5196..75a3b6967 100644 --- a/psycopg3/pq_ctypes.py +++ b/psycopg3/pq_ctypes.py @@ -13,9 +13,9 @@ from ctypes import c_char_p, pointer from .pq_enums import ( ConnStatus, - PostgresPollingStatus, + PollingStatus, TransactionStatus, - PGPing, + Ping, ) from . import _pq_ctypes as impl @@ -55,7 +55,7 @@ class PGconn: def connect_poll(self): rv = impl.PQconnectPoll(self.pgconn_ptr) - return PostgresPollingStatus(rv) + return PollingStatus(rv) def finish(self): self.pgconn_ptr, p = None, self.pgconn_ptr @@ -114,7 +114,7 @@ class PGconn: def reset_poll(self): rv = impl.PQresetPoll(self.pgconn_ptr) - return PostgresPollingStatus(rv) + return PollingStatus(rv) @classmethod def ping(self, conninfo): @@ -124,7 +124,7 @@ class PGconn: raise TypeError("bytes expected, got %r instead" % conninfo) rv = impl.PQping(conninfo) - return PGPing(rv) + return Ping(rv) @property def db(self): diff --git a/psycopg3/pq_enums.py b/psycopg3/pq_enums.py index 5c0958346..cafac184b 100644 --- a/psycopg3/pq_enums.py +++ b/psycopg3/pq_enums.py @@ -24,7 +24,7 @@ class ConnStatus(IntEnum): CONNECTION_CHECK_TARGET = auto() -class PostgresPollingStatus(IntEnum): +class PollingStatus(IntEnum): PGRES_POLLING_FAILED = 0 PGRES_POLLING_READING = auto() PGRES_POLLING_WRITING = auto() @@ -40,7 +40,7 @@ class TransactionStatus(IntEnum): PQTRANS_UNKNOWN = auto() -class PGPing(IntEnum): +class Ping(IntEnum): PQPING_OK = 0 PQPING_REJECT = auto() PQPING_NO_RESPONSE = auto() diff --git a/tests/test_pq.py b/tests/test_pq.py index 177356990..c6a03ed72 100644 --- a/tests/test_pq.py +++ b/tests/test_pq.py @@ -3,7 +3,7 @@ from select import select import pytest -from psycopg3.pq_enums import ConnStatus, PostgresPollingStatus, PGPing +from psycopg3.pq_enums import ConnStatus, PollingStatus, Ping def test_connectdb(pq, dsn): @@ -32,11 +32,11 @@ def test_connect_async(pq, dsn): while 1: assert conn.status != ConnStatus.CONNECTION_BAD rv = conn.connect_poll() - if rv == PostgresPollingStatus.PGRES_POLLING_OK: + if rv == PollingStatus.PGRES_POLLING_OK: break - elif rv == PostgresPollingStatus.PGRES_POLLING_READING: + elif rv == PollingStatus.PGRES_POLLING_READING: select([conn.socket], [], []) - elif rv == PostgresPollingStatus.PGRES_POLLING_WRITING: + elif rv == PollingStatus.PGRES_POLLING_WRITING: select([], [conn.socket], []) else: assert False, rv @@ -49,11 +49,11 @@ def test_connect_async_bad(pq, dsn): while 1: assert conn.status != ConnStatus.CONNECTION_BAD rv = conn.connect_poll() - if rv == PostgresPollingStatus.PGRES_POLLING_FAILED: + if rv == PollingStatus.PGRES_POLLING_FAILED: break - elif rv == PostgresPollingStatus.PGRES_POLLING_READING: + elif rv == PollingStatus.PGRES_POLLING_READING: select([conn.socket], [], []) - elif rv == PostgresPollingStatus.PGRES_POLLING_WRITING: + elif rv == PollingStatus.PGRES_POLLING_WRITING: select([], [conn.socket], []) else: assert False, rv @@ -127,23 +127,23 @@ def test_reset_async(pgconn): pgconn.reset_start() while 1: rv = pgconn.connect_poll() - if rv == PostgresPollingStatus.PGRES_POLLING_READING: + if rv == PollingStatus.PGRES_POLLING_READING: select([pgconn.socket], [], []) - elif rv == PostgresPollingStatus.PGRES_POLLING_WRITING: + elif rv == PollingStatus.PGRES_POLLING_WRITING: select([], [pgconn.socket], []) else: break - assert rv == PostgresPollingStatus.PGRES_POLLING_OK + assert rv == PollingStatus.PGRES_POLLING_OK assert pgconn.status == ConnStatus.CONNECTION_OK def test_ping(pq, dsn): rv = pq.PGconn.ping(dsn) - assert rv == PGPing.PQPING_OK + assert rv == Ping.PQPING_OK rv = pq.PGconn.ping("port=99999") - assert rv == PGPing.PQPING_NO_RESPONSE + assert rv == Ping.PQPING_NO_RESPONSE def test_db(pgconn):