Daniele Varrazzo
e8135ee2cf
Use errors module to catch a specific postgres error
2019-03-16 19:13:58 +00:00
Daniele Varrazzo
b0119fef81
Other import moved to top level in tests
2019-03-16 19:13:58 +00:00
Daniele Varrazzo
8cfe176a85
Dropped repeated conditional import of reload in test
2019-03-16 19:04:40 +00:00
Daniele Varrazzo
aaba4dcf87
TextIOBase moved to tests compat imports
2019-03-16 18:41:59 +00:00
Jon Dufresne
d90ad8627d
Move imports to the top of the module across tests
...
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.
2019-03-16 18:03:41 +00:00
Jon Dufresne
194efc4375
Fix invalid exception handler: except e:
...
Fixes flake8 warning:
./tests/test_connection.py:390:16: F821 undefined name 'e'
./tests/test_connection.py:391:61: F821 undefined name 'e'
./tests/test_connection.py:408:16: F821 undefined name 'e'
./tests/test_connection.py:409:61: F821 undefined name 'e'
In the event of an unexpected error, let the exception bubble up the
stack for a more informative test failure message.
2019-03-16 17:59:18 +00:00
Jon Dufresne
ad4c6a4673
Use unittest 'skip' feature to skip mxDateTimeTests
...
Rather than deleting, the class, use the skip feature. Provides a more
informative message during test output.
Never skip DatetimeTests as all supported Python environments have the
datetime module builtin.
2019-03-13 15:01:34 +00:00
Jon Dufresne
afbbdd18b6
Remove unused variable
...
The variable i is immediately overwritten by the next line.
2019-03-13 11:13:24 +00:00
Jon Dufresne
03bb44dd2c
Convert while 1:
statements to while True:
...
A slightly more readable and modern syntax.
2019-03-13 11:13:05 +00:00
Jon Dufresne
18f5d5ad05
Remove unused imports from tests/test_ipaddress.py
2019-03-13 11:12:48 +00:00
Daniele Varrazzo
a68df50c7b
Added ConnectionInfo.dsn_parameters attribute
2019-02-17 02:37:09 +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
d08be18671
Merge branch 'libpq-ptrs'
2019-02-17 00:17:43 +01:00
Daniele Varrazzo
6bbfce7b89
Skip password encryption test if libpq < 10
2019-02-16 22:57:16 +01:00
Daniele Varrazzo
3b7c083c3d
Skip tests involving ctypes on Windows
...
No idea about how to import libpq.
2019-02-16 18:12:52 +01:00
Daniele Varrazzo
7c7bbb9742
Added connection.pgconn_ptr and cursor.pgresult_ptr
...
Allow interacting with libpq in Python via ctypes.
See #782 .
2019-02-16 18:12:52 +01:00
Daniele Varrazzo
3de4d17519
Fixed use of StandardError in test
...
In Py3 it's gone.
2019-02-11 00:26:01 +00:00
Daniele Varrazzo
30c1befa64
SQLSTATE error classes implemented in C
...
The module is only used to export them to Python.
2019-02-10 03:45:14 +00:00
Daniele Varrazzo
35ec7ad9c1
Use a proper LRU cache for namedtuples
...
Previous one didn't refresh by last use. Use the stdlib version for py3
and one of our own for py2.
Max size set to 512, which should be fine for everyone (tweaking is
still possible by monkeypatching, as the tests do, but I don't want to
make an interface of it).
2019-02-02 19:29:20 +00:00
Daniele Varrazzo
805527fcd6
Added caching of types generated by NamedTupleCursor
...
see #838
2019-02-02 14:22:25 +00:00
Daniele Varrazzo
ddbe495d70
Added BYTESARRAY typecaster
2019-01-18 15:47:01 +00:00
Daniele Varrazzo
4ab4247189
Added test for BYTES typecaster
2019-01-18 15:10:17 +00:00
Daniele Varrazzo
f3695e36c7
Merge remote-tracking branch 'eternalflow/execute-values-returning-clause-support'
2018-12-27 14:53:12 +01:00
Jon Dufresne
eb2d1766c6
Remove unnecessary test decorator 'skip_if_cant_cast'
...
ctypes is available and works on all supported Pythons. It has been
available since Python 2.5. The tests were written when Python 2.4 was
still supported.
2018-12-04 18:20:17 -08:00
Daniele Varrazzo
68bacbb194
Merge pull request #822 from jdufresne/decorate-all
...
Simplify 'decorate_all_tests' usage by decorating the test class
2018-12-04 14:22:02 +00:00
Jon Dufresne
a739c09f67
Simplify 'decorate_all_tests' usage by decorating the test class
...
Skip tests as early as possible by decorating the whole class with
unittest.skipIf instead of every test method individually.
2018-12-01 19:40:27 -08:00
Jon Dufresne
17dc5a85a3
Remove workarounds for unsupported libpq < 9.1
...
Per http://initd.org/psycopg/docs/install.html#prerequisites :
> PostgreSQL client library version from 9.1
2018-12-01 08:58:39 -08:00
Ivan Kotelnikov
b40ac15efc
rename param name to fetch
2018-11-24 20:51:18 +02:00
Ivan Kotelnikov
e2b99d3a8e
write test for fetch_result flag
2018-11-22 12:30:37 +02:00
Daniele Varrazzo
73a680f45d
Convert int subclasses to long before adapting
...
Fixes adaptation of int/long subclasses whose str() is not the number,
such IntEnum
Close #591
Note that I thought it would have needed a new adapter, so I considered
it a new feature. But it is more a shortcoming of the int adapter
failing to do something reasonable (poor Liskov, always mistreated) so I
may actually backport it if there is a new 2.7 release.
2018-11-16 18:16:03 +00:00
Federico Di Gregorio
01f8475f53
Merge branch 'master' into feature-expose-pgconn
2018-11-07 14:15:29 +01:00
Daniele Varrazzo
a83696fc50
Fixed adaptation of lists of empty lists
...
...somehow. Postgres doesn't support them and converts them into a
simple empty array. However this is not really our concern: the syntax
we return is valid.
Close #788
2018-10-30 01:48:51 +00:00
Daniele Varrazzo
2f24a2e22d
Use class decorators to decorate all tests
...
Test decorators changed so that they can be applied either to a method
or to a class. Of course their double nature is implemented by a
decorator.
2018-10-30 00:23:56 +00:00
Daniele Varrazzo
8fb0f694f7
Don't barf on Composite passed to execute_values()
...
Close #794
2018-10-23 01:57:48 +01:00
Daniele Varrazzo
05f9e231a0
Full flake8 3.5 cleanup
2018-10-23 00:39:14 +01:00
Daniele Varrazzo
0236c68da9
Merge branch 'connection-info'
2018-10-15 01:24:00 +01:00
Daniele Varrazzo
b205764fdd
Merge branch 'master' into errors-module
2018-10-15 00:58:32 +01:00
Daniele Varrazzo
e7227ce87b
Added errors.lookup() function
2018-10-15 00:56:51 +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
704e6797e7
Guard from some info functions not available in some libpq versions
2018-10-13 03:09:39 +01:00
Daniele Varrazzo
d138e42ee5
Added ConnectionInfo.parameter_status()
2018-10-13 02:40:17 +01:00
Daniele Varrazzo
9f6a3a5e96
Added ConnectionInfo.ssl_attribute()
2018-10-13 02:21:38 +01:00
Daniele Varrazzo
cb3d5f9d92
Added all the missing ConnectionInfo attributes
2018-10-13 01:36:07 +01:00
Daniele Varrazzo
439dff974d
Added ConnectionInfo.error_message
2018-10-13 00:47:04 +01:00
Daniele Varrazzo
d29aa1c437
Fixed refcount in connection's readonly and deferrable getters
...
Close #790
2018-10-12 23:32:13 +01:00
Daniele Varrazzo
1ac6359fef
Added other members to the ConnectionInfo class
...
Starting deprecating softly some of the methods bloating the connection
class.
2018-10-12 04:18:59 +01:00
Daniele Varrazzo
0a04c8892d
Added several ConnectionInfo attributes
2018-10-12 04:18:59 +01:00
Daniele Varrazzo
0e2b516a3c
Moving host attribute to a connection.info object
2018-10-11 22:42:52 +01:00
Daniele Varrazzo
f99a8de6d0
Added table_oid, table_column on cursor.description items
...
Close #661
2018-10-11 03:37:09 +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