Commit Graph

394 Commits

Author SHA1 Message Date
Daniele Varrazzo
77df287e14 More tests tweaks
Named cursors on old server versions have a different prefetch behaviour.
This has hidden me the supported range of the 24:00 time format.
Let's have another go at full testing...
2015-02-08 12:50:31 +00:00
Daniele Varrazzo
9f7cd6b374 Don't test date 24:00 before PG 8.4 2015-02-08 10:31:28 +00:00
Owen Raccuglia
28180837bf Allow pickling of cursor.description
This is for people using dtuple.py; a dtuple.DatabaseTuple instance
keeps a reference to cursor.description, which is not picklable because
psycopg2 doesn't export the Column namedtuple it uses.

This commit exports the Column namedtuple, and includes a test to verify
the pickle/unpickle works after exporting Column.
2015-02-08 02:36:13 +00:00
Daniele Varrazzo
66fdaeaf09 Propagate read error messages in COPY FROM
Fix ticket #270.
2015-02-08 01:43:37 +00:00
Daniele Varrazzo
7c5bc1b6cf Convert Postgres time 24:00 into 00:00
Fix ticket #278.
2015-02-08 00:42:31 +00:00
Daniele Varrazzo
e3c6b46416 Don't try to close the server cursor in error state
`close()` is implicitly called by `__exit__()`, so an exit on error
would run a query on a inerr connection, causing another exception
hiding the original one. The fix is on `close()`, not on `__exit__()`,
because the semantic of the latter is simply to call the former.

Closes #262.
2014-09-16 06:51:46 +01:00
Daniele Varrazzo
7d312e2da9 Fixed excessively strict notices test
Failing with PG 9.4 because it generates other debug messages during the
test run (rehashing catalog cache).
2014-08-30 14:30:20 +01:00
Daniele Varrazzo
380f7ee4fd Clear adapters in test to maintain reference count 2014-08-26 03:56:09 +01:00
Daniele Varrazzo
3dad8344c0 Added test to verify _psycopg can be imported 2014-08-26 03:55:47 +01:00
Daniele Varrazzo
75a0b2ffe2 Added test to verify withhold cursors work in autocommit 2014-08-21 05:14:20 +01:00
Daniele Varrazzo
18d67a73d5 Added test to verify withhold transaction behaviour
A withhold cursor can read its data when the transaction is closed, so
it shouldn't start a new one upon movement/close.
2014-08-21 05:05:54 +01:00
Daniele Varrazzo
ba1409d419 Added wishful test suite for jsonb type 2014-08-13 00:29:58 +01:00
Daniele Varrazzo
17e9e7d327 Merge branch 'bug-219' into maint_2_5 2014-06-06 21:32:48 +02:00
Daniele Varrazzo
fd0ba0b2d3 Fixed segfault if COPY statements are executed
Close ticket #219
2014-06-06 21:32:08 +02:00
Daniele Varrazzo
d066537efe Added test with objects without length as callproc param 2014-06-05 02:37:06 +02:00
Jason Erickson
6933b3bece Skip test_cleanup_on_badconn_close on Windows
The Windows server version of PostgreSQL uses a function called pgkill in the
file kill.c in place of the UNIX kill function.  This pgkill function
simulates some of the SIGHUP like commands by passing signals through a named
pipe.  Because it is passing the signal through a pipe, the server doesn't get
the kill signal immediately and therefore fails the test on
test_connection.ConnectionTests.test_cleanup_on_badconn_close.
Ideally, the test should check to see if the server is running on Windows, not
the psycopg.
2014-05-18 20:58:50 -06:00
Jason Erickson
9bee072085 Added select.select timeout on AsyncTests.wait
On Windows, the select.select() hangs/waits forever on the
test_async_connection_error_message() test.  Adding a 10 second timeout
allows the tests to continue.
2014-05-18 20:58:23 -06:00
Daniele Varrazzo
06f64fbe70 Skip rowcount on copy test on postgres < 8.2
It looks like the server doesn't send the message.
2014-05-13 14:18:40 +01:00
Daniele Varrazzo
e9335b08f8 Copy operations correctly set the cursor.rowcount attribute
Fixes ticket #180.
2014-05-05 23:52:41 +01:00
Daniele Varrazzo
5a660b80f5 Fixed explicit connection.cursor(cursor_factory=None)
Fixes issue #210.
2014-04-30 17:56:09 +01:00
Daniele Varrazzo
e3ecae75a0 Merge branch 'connection-closed' into maint_2_5
NEWS for released 2.5.3 reordered.
2014-04-05 16:10:32 +01:00
Daniele Varrazzo
e5ab0b3987 Check the connection is really bad on exception before closing it
We end up here without a pgres sometimes (e.g. from lobject errors)
2014-04-05 15:51:39 +01:00
Daniele Varrazzo
2245b56dc1 Fixed overflow opening a lobject with an oid not fitting in a signed int
Fixes 🎫`203`.
2014-04-03 02:35:46 +01:00
Daniele Varrazzo
a516517a23 Dropped unneeded pass in test 2014-04-03 02:31:55 +01:00
Daniele Varrazzo
65fbe9159a Fixed dsn and closed attributes in failing connection subclasses.
From ticket #192 discussion.
2014-04-03 01:41:19 +01:00
Daniele Varrazzo
d6da4ed09f Don't segfault on uninitialized cursor
It can happen with bad cursor subclasses not calling super's init. Raise
an exception instead of segfaulting.

Closes #195
2014-02-26 19:42:29 +00:00
Chris Withers
1487800b6d New implementation of Range sorting that works for Python 2.5 to 3.3, at least. 2014-02-22 23:06:02 +00:00
Chris Withers
ca1845477d Coding style changes. 2014-02-22 23:06:02 +00:00
Chris Withers
f739576f0a Provide a stable and consistent sort order for Range objects.
This matches postgres server-side behaviour and helps client applications that need to sort based on the primary key of tables where the primary key is or contains a range.
2014-02-22 23:06:02 +00:00
Daniele Varrazzo
7e9e11ee27 Check connection type in lobject init
Fixes ticket #187.
2013-11-27 12:42:57 +00:00
Daniele Varrazzo
8d8cc38590 Really test named cursors in test_scroll_named() 2013-10-16 19:09:51 +01:00
Daniele Varrazzo
09cf64dda4 Meaningful connection errors report a meaningful message
Fixes issue #173.
2013-10-16 15:28:16 +01:00
Daniele Varrazzo
0e08fbb20b Fixed pickling of exceptions with no pgerror/pgcode set
Fixes ticket #170.
2013-07-19 16:05:48 +01:00
Daniele Varrazzo
eb36e75b89 Fixed comparison of Range with non-range objects
Fixes ticket #164.

Patch from Chris Withers on master.
2013-06-18 14:16:06 +01:00
Daniele Varrazzo
8fd228dd28 Added regression test for infinity parsing in dates
...and a couple of typos.
2013-05-11 02:24:25 +01:00
Daniele Varrazzo
1e94018473 Added test to verify copysize handling in copy_expert
Not an original psycopg2 bug but present in pure python implementation,
e.g. ctypes issue #25 and cffi issue #5.

https://github.com/mvantellingen/psycopg2-ctypes/issues/25
https://github.com/chtd/psycopg2cffi/pull/5
2013-05-11 02:24:24 +01:00
Daniele Varrazzo
cc4cabebf0 Skip tests on python implementations without getrefcount()
PyPy is one of these.
2013-05-11 02:24:22 +01:00
Piotr Kasprzyk
5f320e52f4 Fix multiple misspellings 2013-04-26 10:32:21 +01:00
Daniele Varrazzo
9e15f54fe8 Added cursor_factory connection attribute and connect() parameter 2013-04-07 02:30:12 +01:00
Daniele Varrazzo
0e06addc9f Testing boilerplate unified in a single base class
The class makes a connection always available, allows creating
new connection and closes everything on tear down.
2013-04-07 00:23:30 +01:00
Daniele Varrazzo
c63d623f65 Merge branch 'drop-py24' into devel 2013-04-05 01:29:25 +01:00
Daniele Varrazzo
736a78f3f6 Avoid encoding strdup in qstring adapter
Dropped encoding parameter in the constructor: it is used
nowhere and not documented. Use directly the connection
encoding if available, else the previous latin1 fallback.
2013-04-05 00:00:42 +01:00
Daniele Varrazzo
546927d44a Use wrap to fix names of decorated test methods
Decorators not using wrap() prevent running the test from command line, e.g.
with:

    python tests/__init__.py test_module.TestSuite.test_method
2013-03-20 23:53:20 +00:00
Daniele Varrazzo
31265e3439 Fixed broken test decorator preventing 3 tests to run 2013-03-20 23:53:19 +00:00
Daniele Varrazzo
b6873ee1ab Dropped support for Python 2.4 2013-03-20 23:40:13 +00:00
Daniele Varrazzo
09629a6dbc Use wrap to fix names of decorated test methods
Decorators not using wrap() prevent running the test from command line, e.g.
with:

    python tests/__init__.py test_module.TestSuite.test_method
2013-03-20 17:26:10 +00:00
Daniele Varrazzo
0c0e2a2455 Fixed broken test decorator preventing 3 tests to run 2013-03-20 17:13:33 +00:00
Daniele Varrazzo
73949cd1b8 Merge branch 'diagnostics' into devel 2013-03-20 01:47:14 +00:00
Daniele Varrazzo
114c62fac8 Added tests to verify the new Diagnostics properties
diag can be used on exceptions raised without cursor and is independent from
the cursor.

Docs updated to reflect the changes.
2013-03-20 00:03:58 +00:00
Daniele Varrazzo
294e7ae080 Tests tweaked to run on all the supported versions 2013-03-18 10:06:07 +00:00