psycopg.git / summary / log / commit / refs

commit    dbe169c652fc33d11a3ea4394ac3f40bd70a070e
Author:   Denis Laxalde <denis.laxalde@dalibo.com>
Commit:   Daniele Varrazzo <daniele.varrazzo@gmail.com>
Date:     Tue Nov 02 10:44:23 2021 +0000

    Catch only expected exception in test_psycopg_dbapi20.py::test_connect_args()


tests/test_psycopg_dbapi20.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/test_psycopg_dbapi20.py b/tests/test_psycopg_dbapi20.py index 1e0f03f2..dbf6670c 100644 --- a/tests/test_psycopg_dbapi20.py +++ b/tests/test_psycopg_dbapi20.py @@ -134,18 +134,17 @@ def test_connect_args(monkeypatch, pgconn, args, kwargs, want): @pytest.mark.parametrize( - "args, kwargs", + "args, kwargs, exctype", [ - (("host=foo", "host=bar"), {}), - (("", ""), {}), - ((), {"nosuchparam": 42}), + (("host=foo", "host=bar"), {}, TypeError), + (("", ""), {}, TypeError), + ((), {"nosuchparam": 42}, psycopg.ProgrammingError), ], ) -def test_connect_badargs(monkeypatch, pgconn, args, kwargs): +def test_connect_badargs(monkeypatch, pgconn, args, kwargs, exctype): def fake_connect(conninfo): return pgconn yield - monkeypatch.setattr(psycopg.connection, "connect", fake_connect) - with pytest.raises((TypeError, psycopg.ProgrammingError)): + with pytest.raises(exctype): psycopg.connect(*args, **kwargs) [parent: 479bdd42d3da]