summaryrefslogtreecommitdiff
path: root/tests/test_cursor.py
Commit message (Collapse)AuthorAgeFilesLines
* Column objects can be slicedcolumn-sliceDaniele Varrazzo2020-03-111-0/+5
| | | | Close #1034.
* Copyright bumped to 2020Daniele Varrazzo2020-01-171-0/+1
|
* Allow tests to be ignored if dynamic binding failed2_8_BETA_2Daniele Varrazzo2019-03-181-6/+10
|
* Other import moved to top level in testsDaniele Varrazzo2019-03-161-2/+2
|
* Move imports to the top of the module across testsJon Dufresne2019-03-161-5/+3
| | | | | | | | | | Allows removing many duplicate imports and better follows PEP8 guidelines: https://www.python.org/dev/peps/pep-0008/#imports > Imports are always put at the top of the file, just after any module > comments and docstrings, and before module globals and constants.
* Copyright year updatedDaniele Varrazzo2019-02-171-1/+1
| | | | | ag -l Copyright | xargs sed -i \ "s/\(.*copyright (C) [0-9]\+\)\(-[0-9]\+\)\?\(.*\)/\1-$(date +%Y)\3/I"
* Added connection.pgconn_ptr and cursor.pgresult_ptrDaniele Varrazzo2019-02-161-0/+18
| | | | | | Allow interacting with libpq in Python via ctypes. See #782.
* Full flake8 3.5 cleanupDaniele Varrazzo2018-10-231-2/+9
|
* Use the connection.info properties instead of the legacy methodsconnection-infoDaniele Varrazzo2018-10-131-7/+7
|
* Added table_oid, table_column on cursor.description itemsdescription-extra-attrsDaniele Varrazzo2018-10-111-1/+22
| | | | Close #661
* Prefer https:// URLs when availableJon Dufresne2018-09-221-1/+1
|
* Bump tests for selective closure of named cursor to pg 8.2Daniele Varrazzo2018-07-241-1/+1
| | | | | Previous versions don't support the features as they don't have the pg_cursors view. But they are too old to care.
* Close named cursor if exist, even if we didn't run executeDaniele Varrazzo2018-07-241-0/+13
| | | | Close #746
* Merge branch 'master' into drop-2to3Daniele Varrazzo2018-05-201-0/+11
|\
| * Don't raise an exception closing an unused named cursorfix-716Daniele Varrazzo2018-05-201-0/+5
| | | | | | | | Close #716
| * 'cursor.mogrify()' can be called on closed cursorsmogrify-on-closed-cursorDaniele Varrazzo2018-01-111-0/+6
| | | | | | | | Fix #579.
* | In tests, use compat.py where there is overlapJon Dufresne2017-12-111-2/+3
|/
* Avoid installing tests to site-packagesJon Dufresne2017-12-101-1/+1
| | | | | | | | 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.
* Use relative imports throughout testsJon Dufresne2017-12-101-1/+1
| | | | | | | | | | | | | | 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/
* Fix use of "async" in test_cursor.pyJon Dufresne2017-12-101-1/+1
| | | | | "async" will be a keyword starting with Python 3.7. On Python 3.6, use of "async" causes a deprecation warning. Use the alias "async_" instead.
* Merge remote-tracking branch 'jdufresne/import-unittest'Daniele Varrazzo2017-12-021-1/+2
|\
| * Always import the system unittestJon Dufresne2017-12-011-1/+2
| | | | | | | | | | | | | | 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.
* | Use builtin function next() throughout projectJon Dufresne2017-12-011-2/+2
|/ | | | | | | Available since Python 2.6. Use of .next() is deprecated and not supported in Python 3. Forward compatible with modern Python. https://docs.python.org/2/library/functions.html#next
* Collect rowcount in executemany even when discarding resultsDaniele Varrazzo2017-11-291-0/+14
| | | | Closes #633.
* Merge remote-tracking branch 'jdufresne/decimal'Daniele Varrazzo2017-11-281-11/+3
|\
| * Remove workaround for decimal moduleJon Dufresne2017-11-261-11/+3
| | | | | | | | | | | | | | | | The decimal module is available on all Python versions supported by psycopg2. It has been available since Python 2.4. No need to catch an ImportError. https://docs.python.org/2/library/decimal.html
* | Remove workarounds for namedtuple on Python <= 2.5Jon Dufresne2017-11-261-2/+1
|/ | | | | | namedtuple is available on all Python versions supported by psycopg2. It was first introduced in Python 2.6. Can remove all workarounds and special documentation.
* Bunch of test tweaks to make the test grid greenDaniele Varrazzo2017-03-141-2/+12
|
* Always raise OperationalError when connection was closed externally.Greg Ward2017-03-141-1/+1
| | | | | | | | | | | | | | | From the DB-API (https://www.python.org/dev/peps/pep-0249/): OperationalError Exception raised for errors that are related to the database's operation and not necessarily under the control of the programmer, e.g. an unexpected disconnect occurs, [...] Additionally, psycopg2 was inconsistent, at least in the async case: depending on how the "connection closed" error was reported from the kernel to libpq, it would sometimes raise OperationalError and sometimes DatabaseError. Now it always raises OperationalError.
* Always detect when a connection is closed behind psycopg2's back.Greg Ward2017-03-141-0/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There's a race condition that only seems to happen over Unix-domain sockets. Sometimes, the closed socket is reported by the kernel to libpq like this (captured with strace): sendto(3, "Q\0\0\0\34select pg_backend_pid()\0", 29, MSG_NOSIGNAL, NULL, 0) = 29 recvfrom(3, "E\0\0\0mSFATAL\0C57P01\0Mterminating "..., 16384, 0, NULL, NULL) = 110 recvfrom(3, 0x12d0330, 16384, 0, 0, 0) = -1 ECONNRESET (Connection reset by peer) That is, psycopg2/libpq sees no error when sending the first query after the connection is closed, but gets an error reading the result. In that case, everything worked fine. But sometimes, the error manifests like this: sendto(3, "Q\0\0\0\34select pg_backend_pid()\0", 29, MSG_NOSIGNAL, NULL, 0) = -1 EPIPE (Broken pipe) recvfrom(3, "E\0\0\0mSFATAL\0C57P01\0Mterminating "..., 16384, 0, NULL, NULL) = 110 recvfrom(3, "", 16274, 0, NULL, NULL) = 0 recvfrom(3, "", 16274, 0, NULL, NULL) = 0 i.e. libpq received an error when sending the query. This manifests as a slightly different exception from a slightly different place. More importantly, in this case connection.closed is left at 0 rather than being set to 2, and that is the bug I'm fixing here. Note that we see almost identical behaviour for sync and async connections, and the fixes are the same. So I added extremely similar test cases. Finally, there is still a bug here: for async connections, we sometimes raise DatabaseError (incorrect) and sometimes raise OperationalError (correct). Will fix that next.
* Flake8 complaintsDaniele Varrazzo2017-03-141-12/+8
|
* Deal consistently with E'' quotes in testsDaniele Varrazzo2017-02-061-6/+6
|
* Allow skipping the slow testmanylinuxDaniele Varrazzo2017-02-021-2/+3
| | | | | | | | 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.
* Merge branch 'master' into named-callprocDaniele Varrazzo2016-12-261-23/+31
|\
| * Fix unicode mogrify test on python 2Daniele Varrazzo2016-10-111-3/+9
| |
| * Python source cleanup using flake8Daniele Varrazzo2016-10-111-17/+20
| |
| * Dropped use of b() "macro" and 2to3 fixerDaniele Varrazzo2016-08-151-9/+8
| | | | | | | | Just use the b"" strings syntax supported from python 2.6.
* | Added test with objects without length as callproc paramDaniele Varrazzo2015-12-121-0/+5
| |
* | Raise TypeError if the dict in callproc param contains non-stringsDaniele Varrazzo2015-12-121-3/+3
| | | | | | | | | | Check-and-conversion chain fixed and simplified. 'spname' was a reference leak.
* | callproc: tests, docs, and comment/error-reporting touchups.mrmilosz2015-12-121-0/+37
|/
* Allow pickling of cursor.descriptionOwen Raccuglia2015-02-081-0/+11
| | | | | | | | | 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.
* Added test to verify withhold cursors work in autocommitDaniele Varrazzo2014-08-211-0/+22
|
* Added test to verify withhold transaction behaviourDaniele Varrazzo2014-08-211-4/+30
| | | | | A withhold cursor can read its data when the transaction is closed, so it shouldn't start a new one upon movement/close.
* Added test with objects without length as callproc paramDaniele Varrazzo2014-06-061-0/+4
|
* Don't segfault on uninitialized cursorDaniele Varrazzo2014-02-261-0/+14
| | | | | | | It can happen with bad cursor subclasses not calling super's init. Raise an exception instead of segfaulting. Closes #195
* Really test named cursors in test_scroll_named()Daniele Varrazzo2013-10-161-3/+1
|
* Skip tests on python implementations without getrefcount()Daniele Varrazzo2013-05-061-1/+3
| | | | PyPy is one of these.
* Testing boilerplate unified in a single base classDaniele Varrazzo2013-04-071-9/+3
| | | | | The class makes a connection always available, allows creating new connection and closes everything on tear down.
* Added support with cursors without scroll clauseDaniele Varrazzo2012-08-151-1/+27
| | | | | Using nothing is different from NO SCROLL, see DECLARE notes in PG docs.
* Added test for scrollable cursorDaniele Varrazzo2012-08-151-0/+39
|