diff options
author | Marco De Paoli <depaolim@gmail.com> | 2018-10-05 09:23:13 +0200 |
---|---|---|
committer | Marco De Paoli <depaolim@gmail.com> | 2018-10-06 15:19:01 +0200 |
commit | 1c553bb703d5b087e1f5b7966584c70b0b8a196a (patch) | |
tree | f3b2be0a949b6fc10a00371663412dfa143333b7 /tests/test_connection.py | |
parent | 9d83b036059d88b49477d5a068b4fad84076de30 (diff) | |
download | psycopg2-1c553bb703d5b087e1f5b7966584c70b0b8a196a.tar.gz |
Added connection.host
Return the server host name of the current connect.
Diffstat (limited to 'tests/test_connection.py')
-rwxr-xr-x | tests/test_connection.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/test_connection.py b/tests/test_connection.py index 1342f9f..498f351 100755 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -39,7 +39,7 @@ from .testutils import ( skip_after_postgres, skip_before_libpq, skip_after_libpq, ConnectingTestCase, skip_if_tpc_disabled, skip_if_windows, slow) -from .testconfig import dsn, dbname +from .testconfig import dbhost, dsn, dbname class ConnectionTests(ConnectingTestCase): @@ -1682,6 +1682,19 @@ while True: self.assert_(not err, err) +class TestConnectionProps(ConnectingTestCase): + def test_host(self): + self.assertFalse(self.conn.closed) + expected = dbhost if dbhost else "/" + self.assertIn(expected, self.conn.host) + + def test_host_readonly(self): + self.assertFalse(self.conn.closed) + with self.assertRaises(AttributeError): + self.conn.host = 'override' + + + def test_suite(): return unittest.TestLoader().loadTestsFromName(__name__) |