Commit Graph

58 Commits

Author SHA1 Message Date
Rafi Shamim
3c58e96e10 Unskip tests that work on CockroachDB v22.1
CockroachDB supports named cursors in v22.1, so more tests pass.
2022-03-28 20:26:23 +02:00
Daniele Varrazzo
1d3a89a0bb Copyright year updated to 2021
ag -l Copyright | xargs sed -i \
    "s/\(.*copyright (C) [0-9]\+\)\(-[0-9]\+\)\?\(.*Psycopg Team.*\)/\1-$(date +%Y)\3/I"
2021-06-15 00:37:22 +01:00
Hugo van Kemenade
7babeccbec Upgrade Python syntax with pyupgrade --py36-plus 2020-11-17 22:22:11 +02:00
Daniele Varrazzo
6d8382b7ed Added missing reasons for crdb skip
Added check to make sure a reason must be passed.
2020-08-17 21:27:25 +01:00
Daniele Varrazzo
6eb4fab1db Added reason for skipping on CockroachDB 2020-07-27 23:03:26 +01:00
Daniele Varrazzo
f8c1cff6a3 Skip cancel tests on CockroachDB
One test moved to the async tests module, as it really belongs there.
2020-07-21 22:21:32 +01:00
Daniele Varrazzo
ee34198bf6 All the sync tests pass on CockroachDB
Added decorator to skip tests on crdb
2020-07-21 22:21:24 +01:00
Daniele Varrazzo
659910ee81 Allow most of the async tests to pass on CockroachDB
Added function to get crdb version from a connection
2020-07-21 01:43:57 +01:00
Daniele Varrazzo
5e0b02afb2 Copyright bumped to 2020 2020-01-17 21:21:11 +00:00
Daniele Varrazzo
2f094841b2 Slow test is slow 2019-10-19 16:29:16 +01:00
Daniele Varrazzo
46106e1b78 Test notifies are received ok polling an async cur 2019-04-05 19:04:48 +01:00
Daniele Varrazzo
755a128ffb Handle ok poll() without a cursor having executed queries
Close #887
2019-04-05 18:04:55 +01:00
Daniele Varrazzo
734845b79a Added pq_get_result_async() replaced pg_get_last_result()
The new function keeps together PQconsumeInput() with PQisBusy(), in
order to handle the condition in which not all the results of a sequence
of statements arrive in the same roundtrip.

Added pointer to a PGresult to the connection to keep the state across
async communication: it can probably be used to simplify other code
paths where a result is brought forward manually.

Close #802
Close #855
Close #856
2019-03-17 01:20:06 +00:00
Daniele Varrazzo
b0119fef81 Other import moved to top level in tests 2019-03-16 19:13:58 +00:00
Daniele Varrazzo
599432552a Copyright year updated
ag -l Copyright | xargs sed -i \
        "s/\(.*copyright (C) [0-9]\+\)\(-[0-9]\+\)\?\(.*\)/\1-$(date +%Y)\3/I"
2019-02-17 01:36:36 +00:00
Daniele Varrazzo
05f9e231a0 Full flake8 3.5 cleanup 2018-10-23 00:39:14 +01:00
Daniele Varrazzo
44bd2927c5 Use the connection.info properties instead of the legacy methods 2018-10-13 03:28:42 +01:00
Daniele Varrazzo
c314512115 Fixed infinite loop in pq_get_last_result after COPY
There will be an error downstream but we have to get out of this
function first.

Close #781
2018-10-10 23:57:34 +01:00
Jon Dufresne
389f6c08d9 Avoid installing tests to site-packages
For library end users, there is no need to install tests alongside the
package itself. This keeps the tests available for development without
adding extra packages to user's site-packages directory. Reduces the
size of the installed package. Avoids accidental execution of test code
by an installed package.
2017-12-10 10:55:58 -08:00
Jon Dufresne
1a8e992fcc Use relative imports throughout tests
The tests relied on Python2 relative import semantics. Python3 changed
import semantics to always search sys.path by default. To import using a
relative path it must have a leading dot.

Forward compatible with newer Pythons.

Works towards the goal of moving tests outside of the installed package.

For more information, see PEP-328:

https://www.python.org/dev/peps/pep-0328/
2017-12-10 10:51:07 -08:00
Jon Dufresne
fcc083dc12 Always import the system unittest
There is no need to import testutils.unittest instead of simply
unittest. They are simple aliases. Use system unittest to be more
regular, consistent as well as idiomatic with the wider Python
community.
2017-12-01 18:35:30 -08:00
Jon Dufresne
390e43fcb1 Use modern except syntax throughout project
The syntax "except Exception, exc:" is deprecated. All Python versions
supported by psycopg2 support the newer, modern syntax. Forward
compatible with future Python versions.
2017-11-20 20:00:35 -08:00
Daniele Varrazzo
d50ed48807 Added readonly and deferrable attributes 2017-02-16 12:46:35 +00:00
Daniele Varrazzo
1911b250e3 Merge branch 'async-keyword'
Close #495
2017-02-03 04:45:17 +00:00
Daniele Varrazzo
ce9be69615 Added async_ as an alias for async
Added in argument for psycopg2.connect() and connection.__init__, and
for the connection.async attribute.
2017-02-03 04:43:49 +00:00
Daniele Varrazzo
d8b1fbd905 Further skipping of slow tests 2017-02-02 03:02:29 +00:00
Daniele Varrazzo
f24de0357f Allow skipping the slow test
It's not so much about tests being slow: some just get stuck and timeout
travis.

Skipped all tests taking about more than 0.2s to run on my laptop.
Fast testing takes about 8s instead of 24.
2017-02-02 01:53:50 +00:00
Daniele Varrazzo
91d2158de7 Python source cleanup using flake8 2016-10-11 00:11:55 +01:00
Oleksandr Shulgin
cf4f2411bf Fix async replication and test. 2015-10-15 18:01:43 +02:00
Jason Erickson
c5f2e29dde 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-19 12:15:52 +01:00
Daniele Varrazzo
1e623a951c Meaningful connection errors report a meaningful message
Fixes issue #173.
2013-10-16 17:50:10 +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
Catalin Iacob
7abe1775d0 Fix tests for Postgres 9.3
Postgres 9.3 turns messages about implicit indexes and sequences from NOTICE
to DEBUG1 so the tests fail with a default 9.3 server configuration because
the client doesn't get any NOTICE. Fix it by also asking for DEBUG1 messages
from the server when testing against Postgres >= 9.3.
2013-03-16 00:54:11 +00:00
Daniele Varrazzo
702ae0a904 Force GC during weakref tests
Required to run the tests under PyPy with no refcount. See
https://github.com/mvantellingen/psycopg2-ctypes/pull/15#issuecomment-3274618
2011-12-26 22:35:33 +01:00
Daniele Varrazzo
c96ba553da Cleanup of skipping of testing methods on certain Py/PG versions 2011-02-15 17:11:07 +00:00
Daniele Varrazzo
79048ff19a Merge branch 'python2' into python3
Conflicts:
	NEWS-2.3
	tests/__init__.py
	tests/test_lobject.py
	tests/test_quote.py
	tests/testutils.py
2011-01-10 00:46:02 +00:00
Daniele Varrazzo
15a09da96d Added license to unit tests
As the test suite is now part of the source distribution.
2011-01-09 23:44:35 +00:00
Daniele Varrazzo
80bd6e2794 Merge branch 'python2' into python3
Conflicts:
	NEWS-2.3
	psycopg/connection_type.c
	tests/test_connection.py
	tests/types_basic.py
2011-01-03 21:43:02 +01:00
Daniele Varrazzo
5f6e773575 Broken circular reference in async execution
If a connection is destroyed before an async operation is completed, the
`async_cursor` member creates a reference loop, leaving the connection and
the cursor alive. `async_cursor` is now a weak reference.
2011-01-03 21:34:49 +01:00
Daniele Varrazzo
ade1b2cc7b Test suite converted into a proper package.
Dropped cyclic import from modules to tests: they were only working
because a second copy of the package was found in the project dir.
Use relative import so that 2to3 can do a good conversion.
2010-12-21 05:02:19 +00:00
Daniele Varrazzo
598b9424d2 Deal uniformly with test servers without pg_sleep. 2010-11-28 17:29:36 +00:00
Daniele Varrazzo
9f78141532 Don't consider the kernel not blocking us on write as an error. 2010-11-25 03:13:49 +00:00
Daniele Varrazzo
19ead4a5cb Test cleanup.
Tests pass or fail gracefully on older PostgreSQL versions.

If unittest2 is available, skip tests instead of printing warnings.
2010-11-19 03:55:37 +00:00
Daniele Varrazzo
df959c20be Making sync and async connection setup somewhat more consistent. 2010-04-23 13:24:35 +01:00
Daniele Varrazzo
12ef826d50 Dropped redundant call to conn_notice_process().
If the connection is sync, notices will be processed by pq_fetch()
downstream.

If the connection is async, here we have only sent the query: no result
is ready yet, and neither notices have had a chance to arrive: they will
be retrieved later by pq_is_busy().

Added tests to check the above statement don't break.
2010-04-21 15:09:14 +01:00
Daniele Varrazzo
6fecc36b7f Connection method 'executing()' renamed to 'isexecuting()'. 2010-04-21 15:09:13 +01:00
Daniele Varrazzo
7ee09353ec Connection method 'issync()' changed into the attribute 'async'. 2010-04-21 15:09:13 +01:00
Jan Urbański
067161d5f3 Remove fileno() and poll() from cursors
Instead, the code should be using the fileno() and poll() methods of
the cursor's connection. Handle the case when poll() is called on an
already built connection as a request to poll the asynchronous query
(if there is one) and get NOTIFY events.
Update the tests to reflect that change, add a test for NOTIFY.
2010-04-21 15:09:13 +01:00
Jan Urbański
f06f557111 Add one more test for errors involving two cursors 2010-04-20 23:01:10 +01:00
Jan Urbański
c4ebc0f702 Handle errors in asynchronous queries.
Do it by keeping the reference to the last PGresult in the cursor and
calling pq_fetch() before ending the asynchronous execution. This
takes care of handling the possible error state of the PGresult and
also allows the removal of the needsfetch flag, since now after
execution ends the results are already fetched and parsed.
2010-04-20 23:01:01 +01:00