MCPcopy
hub / github.com/psycopg/psycopg / test_used_password

Function test_used_password

tests/pq/test_pgconn.py:374–389  ·  view source on GitHub ↗
(pgconn, dsn, monkeypatch)

Source from the content-addressed store, hash-verified

372
373
374def test_used_password(pgconn, dsn, monkeypatch):
375 assert isinstance(pgconn.used_password, bool)
376
377 # Assume that if a password was passed then it was needed.
378 # Note that the server may still need a password passed via pgpass
379 # so it may be that has_password is false but still a password was
380 # requested by the server and passed by libpq.
381 info = pq.Conninfo.parse(dsn.encode())
382
383 if "PGPASSWORD" in os.environ:
384 assert pgconn.used_password
385 if [i for i in info if i.keyword == b"password"][0].val is not None:
386 assert pgconn.used_password
387
388 pgconn.finish()
389 pgconn.used_password
390
391
392@pytest.mark.libpq(">= 16")

Callers

nothing calls this directly

Calls 2

parseMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected