MCPcopy Create free account
hub / github.com/MagicStack/asyncpg / verify_fails

Method verify_fails

tests/test_connect.py:1897–1912  ·  view source on GitHub ↗
(sslmode, *, host='localhost', exn_type)

Source from the content-addressed store, hash-verified

1895 await con.close()
1896
1897 async def verify_fails(sslmode, *, host='localhost', exn_type):
1898 # XXX: uvloop artifact
1899 old_handler = self.loop.get_exception_handler()
1900 con = None
1901 try:
1902 self.loop.set_exception_handler(lambda *args: None)
1903 with self.assertRaises(exn_type):
1904 con = await self.connect(
1905 dsn='postgresql://foo/?sslmode=' + sslmode,
1906 host=host,
1907 user='ssl_user')
1908 await con.fetchval('SELECT 42')
1909 finally:
1910 if con:
1911 await con.close()
1912 self.loop.set_exception_handler(old_handler)
1913
1914 invalid_auth_err = asyncpg.InvalidAuthorizationSpecificationError
1915 await verify_fails('disable', exn_type=invalid_auth_err)

Callers

nothing calls this directly

Calls 3

connectMethod · 0.45
fetchvalMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected