From: Daniele Varrazzo Date: Tue, 24 Aug 2021 15:58:34 +0000 (+0200) Subject: Drop Cursor.status property X-Git-Tag: 3.0.beta1~47 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0f4f53962b00efc4a739523a8b452cea8aad4e65;p=thirdparty%2Fpsycopg.git Drop Cursor.status property --- diff --git a/psycopg/psycopg/cursor.py b/psycopg/psycopg/cursor.py index 17807790c..f1f9274d7 100644 --- a/psycopg/psycopg/cursor.py +++ b/psycopg/psycopg/cursor.py @@ -98,12 +98,6 @@ class BaseCursor(Generic[ConnectionType, Row]): """`True` if the cursor is closed.""" return self._closed - @property - def status(self) -> Optional[pq.ExecStatus]: - # TODO: do we want this? - res = self.pgresult - return pq.ExecStatus(res.status) if res else None - @property def query(self) -> Optional[bytes]: """The last query sent to the server, if available.""" diff --git a/tests/test_cursor.py b/tests/test_cursor.py index 2962afa7d..d1875aeec 100644 --- a/tests/test_cursor.py +++ b/tests/test_cursor.py @@ -42,17 +42,6 @@ def test_weakref(conn): assert w() is None -def test_status(conn): - cur = conn.cursor() - assert cur.status is None - cur.execute("reset all") - assert cur.status == cur.ExecStatus.COMMAND_OK - cur.execute("select 1") - assert cur.status == cur.ExecStatus.TUPLES_OK - cur.close() - assert cur.status == cur.ExecStatus.TUPLES_OK - - def test_execute_many_results(conn): cur = conn.cursor() assert cur.nextset() is None @@ -84,7 +73,7 @@ def test_execute_sequence(conn): def test_execute_empty_query(conn, query): cur = conn.cursor() cur.execute(query) - assert cur.status == cur.ExecStatus.EMPTY_QUERY + assert cur.pgresult.status == cur.ExecStatus.EMPTY_QUERY with pytest.raises(psycopg.ProgrammingError): cur.fetchone() diff --git a/tests/test_cursor_async.py b/tests/test_cursor_async.py index 0c61a2fa5..bbc81bdd7 100644 --- a/tests/test_cursor_async.py +++ b/tests/test_cursor_async.py @@ -42,17 +42,6 @@ async def test_weakref(aconn): assert w() is None -async def test_status(aconn): - cur = aconn.cursor() - assert cur.status is None - await cur.execute("reset all") - assert cur.status == cur.ExecStatus.COMMAND_OK - await cur.execute("select 1") - assert cur.status == cur.ExecStatus.TUPLES_OK - await cur.close() - assert cur.status == cur.ExecStatus.TUPLES_OK - - async def test_execute_many_results(aconn): cur = aconn.cursor() assert cur.nextset() is None @@ -87,7 +76,7 @@ async def test_execute_sequence(aconn): async def test_execute_empty_query(aconn, query): cur = aconn.cursor() await cur.execute(query) - assert cur.status == cur.ExecStatus.EMPTY_QUERY + assert cur.pgresult.status == cur.ExecStatus.EMPTY_QUERY with pytest.raises(psycopg.ProgrammingError): await cur.fetchone()