diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2018-02-20 17:33:12 +0000 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2018-02-21 10:27:28 +0000 |
commit | ea923b63a48880d3d229241de42813a822e5db1e (patch) | |
tree | 741d4a0c207f7a652dd5647ab757cdcc44e031df /tests/test_connection.py | |
parent | 0a5db6ecf5568b976ae67fbedc04c72c4aec92f2 (diff) | |
download | psycopg2-fix-679.tar.gz |
Allow strings subclasses in ensure_bytesfix-679
Fix #679
Diffstat (limited to 'tests/test_connection.py')
-rwxr-xr-x | tests/test_connection.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test_connection.py b/tests/test_connection.py index a82bd49..4625e7e 100755 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -246,6 +246,13 @@ class ConnectionTests(ConnectingTestCase): else: del os.environ['PGCLIENTENCODING'] + def test_connect_no_string(self): + class MyString(str): + pass + + conn = psycopg2.connect(MyString(dsn)) + conn.close() + def test_weakref(self): from weakref import ref import gc @@ -400,6 +407,13 @@ class ParseDsnTestCase(ConnectingTestCase): self.assertRaises(TypeError, ext.parse_dsn, None) self.assertRaises(TypeError, ext.parse_dsn, 42) + def test_str_subclass(self): + class MyString(str): + pass + + res = ext.parse_dsn(MyString("dbname=test")) + self.assertEqual(res, {'dbname': 'test'}) + class MakeDsnTestCase(ConnectingTestCase): def test_empty_arguments(self): |