tlocke / pg8000

A Pure-Python PostgreSQL Driver
BSD 3-Clause "New" or "Revised" License
515 stars 46 forks source link

Fix tests #104

Closed yan12125 closed 2 years ago

yan12125 commented 2 years ago

Fix the following two test failures during pyest test:

Test logs ``` ___________________________________ test_ssl ___________________________________ db_kwargs = {'host': '127.0.0.1', 'password': 'pw', 'port': 57053, 'ssl_context': , ...} def test_ssl(db_kwargs): context = ssl.create_default_context() context.check_hostname = False db_kwargs["ssl_context"] = context > with pg8000.connect(**db_kwargs): test/legacy/test_auth.py:26: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ pg8000/__init__.py:117: in connect return Connection( pg8000/legacy.py:442: in __init__ super().__init__(*args, **kwargs) pg8000/core.py:255: in __init__ self._usock = ssl_context.wrap_socket(self._usock, server_hostname=host) /usr/lib/python3.10/ssl.py:512: in wrap_socket return self.sslsocket_class._create( /usr/lib/python3.10/ssl.py:1070: in _create self.do_handshake() _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = block = False @_sslcopydoc def do_handshake(self, block=False): self._check_connected() timeout = self.gettimeout() try: if timeout == 0.0 and block: self.settimeout(None) > self._sslobj.do_handshake() E ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:997) /usr/lib/python3.10/ssl.py:1341: SSLCertVerificationError ___________________________________ test_ssl ___________________________________ db_kwargs = {'host': '127.0.0.1', 'password': 'pw', 'port': 57053, 'ssl_context': , ...} def test_ssl(db_kwargs): context = ssl.create_default_context() context.check_hostname = False db_kwargs["ssl_context"] = context > with pg8000.native.Connection(**db_kwargs): test/native/test_auth.py:27: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ pg8000/native.py:179: in __init__ super().__init__(*args, **kwargs) pg8000/core.py:255: in __init__ self._usock = ssl_context.wrap_socket(self._usock, server_hostname=host) /usr/lib/python3.10/ssl.py:512: in wrap_socket return self.sslsocket_class._create( /usr/lib/python3.10/ssl.py:1070: in _create self.do_handshake() _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = block = False @_sslcopydoc def do_handshake(self, block=False): self._check_connected() timeout = self.gettimeout() try: if timeout == 0.0 and block: self.settimeout(None) > self._sslobj.do_handshake() E ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:997) /usr/lib/python3.10/ssl.py:1341: SSLCertVerificationError ```

I noticed this when upgrading I'm the Arch Linux package python-pg8000 to 1.26.0. Apparently those failures do not happen in GitHub Actions as they are ignored.

tlocke commented 2 years ago

Hi @yan12125, your patch has prompted me to take another look at the tests, and now I've changed things so that all the tests should be run by both Github Actions and also by running tox from the command line. So everything should work for you now with release 1.26.1, but let me know if there's still a problem.

yan12125 commented 2 years ago

Thanks! All tests pass with 1.26.1. I think this PR can be closed?

tlocke commented 2 years ago

Brilliant, glad it's all working 🙂