From: Denis Laxalde Date: Tue, 2 Nov 2021 10:44:23 +0000 (+0100) Subject: Catch only expected exception in test_psycopg_dbapi20.py::test_connect_args() X-Git-Tag: 3.0.2~3^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dbe169c652fc33d11a3ea4394ac3f40bd70a070e;p=thirdparty%2Fpsycopg.git Catch only expected exception in test_psycopg_dbapi20.py::test_connect_args() --- diff --git a/tests/test_psycopg_dbapi20.py b/tests/test_psycopg_dbapi20.py index 1e0f03f23..dbf6670ce 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)