Commit Graph

150 Commits

Author SHA1 Message Date
Daniele Varrazzo
dfb301b42b Use PY2, PY3 for conditional code instead of sys.version_info 2019-03-16 19:54:40 +00:00
Daniele Varrazzo
b0119fef81 Other import moved to top level in tests 2019-03-16 19:13:58 +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
afbbdd18b6 Remove unused variable
The variable i is immediately overwritten by the next line.
2019-03-13 11:13:24 +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
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
Federico Di Gregorio
01f8475f53
Merge branch 'master' into feature-expose-pgconn 2018-11-07 14:15:29 +01: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
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
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
Federico Di Gregorio
81addddaee Added connection.get_native_connection() 2018-10-07 13:54:24 +02:00
Marco De Paoli
1c553bb703 Added connection.host
Return the server host name of the current connect.
2018-10-06 15:19:01 +02:00
Daniele Varrazzo
344ce15261 Better testing of encryption function with libpq < 10 2018-08-17 02:09:22 +01:00
Daniele Varrazzo
9cf658ec6e Fixed refcount handling in encrypt_password
Added tests to check bad types, which discovered the above problem: on
type error we would have decref'd on exit something that was only
borrowed (because we wouldn't have performed matching increfs).
2018-05-20 21:18:36 +01:00
Daniele Varrazzo
abca14d601 Fixed keywords support for encrypt_password and tests completed 2018-05-20 20:50:04 +01:00
Daniele Varrazzo
a3063900ee Fixed code flow in encrypt_password()
Fixed several shortcomings highlighted in #576 and not fixed as
requested.

Also fixed broken behaviour of ignoring the algorithm if the connection
is missing.
2018-05-20 19:18:42 +01:00
Ashesh Vashi
1bec2bdc43
Merge branch 'master' into master 2018-05-08 15:17:59 +05:30
Daniele Varrazzo
ea923b63a4 Allow strings subclasses in ensure_bytes
Fix #679
2018-02-21 10:27:28 +00:00
Daniele Varrazzo
76f3e196d3 Silence warning on import failing a test 2018-01-29 03:23:59 +00:00
Daniele Varrazzo
74d2c4bef9 Fixed idempotence check changing connection characteristics 2018-01-11 02:23:27 +00: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
699be52e8b Remove unnecessary script_to_py3; make scripts compatible instead
Part of the work towards moving tests out of the installed package.
2017-12-01 22:50:16 -08:00
Hugo
ffcc65d4f0 Drop support for EOL Python 2.6 2017-11-28 16:02:12 +00: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
Ashesh Vashi
84d405894c Moving the encrypt_password method from the connection class to the
psycopgmodule, and exported it from psycopg2.extensions as per review
comments.
2017-09-14 23:42:54 +05:30
Ashesh Vashi
6e0edf7779 Merge remote-tracking branch 'psycopg2/master' 2017-09-11 18:26:34 +05:30
Daniele Varrazzo
d619baf000 Skipped a couple of test with unsupported postgres features 2017-07-22 02:09:24 +01:00
Ashesh Vashi
e089d94c88 'encrypt_password' raises 'psycopg2.NotSupportedErorr' exception for
server version >= 10, when compiled using libpq version < 10, when no
algorithm is specified.
2017-07-17 11:46:50 +05:30
Ashesh Vashi
2c1966a7f6 When compiled with libpq version < 10, it raises 'psycopg2.NotSupportedError' (not, psycopg2.ProgrammingError). 2017-07-17 11:06:55 +05:30
Ashesh Vashi
cfb0937605 Added support for preparing the encrypted password of a PostgreSQL
password using the libpq functions - 'PQencryptPasswordConn', and
'PQencryptPassword'.
2017-07-17 10:32:59 +05:30
Daniele Varrazzo
30d89da4fa Ignore spurious output in test with Python debug build 2017-06-17 03:20:09 +01:00
Daniele Varrazzo
7ae2cb5cd0 Don't force a valid return code for the test
Windows returns 22, Linux returns 1
2017-06-15 17:39:00 +01:00
Daniele Varrazzo
de843ef756 Added test to reproduce bug #551 2017-06-15 17:22:32 +01:00
Daniele Varrazzo
9f160fd820 Obscure the password on url dsn too
Note that we don't leak anymore the password length.

Fix #528
2017-03-16 03:53:40 +00:00
Daniele Varrazzo
cc047a445a Added tests to verify the password is obscured
The url test fails: see issue #528
2017-03-15 16:00:40 +00:00
Daniele Varrazzo
8e28444897 Bunch of test tweaks to make the test grid green 2017-03-14 14:15:52 +00:00