Skip to content
This repository was archived by the owner on May 29, 2026. It is now read-only.

python: fix broken tests#37

Merged
odeke-em merged 1 commit into
google:masterfrom
aabmass:fix-py-tests
Jan 11, 2021
Merged

python: fix broken tests#37
odeke-em merged 1 commit into
google:masterfrom
aabmass:fix-py-tests

Conversation

@aabmass

@aabmass aabmass commented Jan 11, 2021

Copy link
Copy Markdown
Member

Tests were previously failing because psycopg2.__libpq_version__ is an int:

======================================================================
ERROR: test_dbapi_threadsafety (tests.psycopg2.tests.Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/aaronabbott/src/tests/psycopg2/tests.py", line 54, in test_dbapi_threadsafety
    with_dbapi_threadsafety=True,
  File "/home/aaronabbott/src/tests/psycopg2/tests.py", line 36, in assertSQL
    self.assertEqual(cursor.execute(None, 'SELECT 1;'), 'worked')
  File "/home/aaronabbott/src/.tox/py36-psycopg2/lib/python3.6/site-packages/google/cloud/sqlcommenter/psycopg2/extension.py", line 70, in execute
    sql += generate_sql_comment(**data)
  File "/home/aaronabbott/src/.tox/py36-psycopg2/lib/python3.6/site-packages/google/cloud/sqlcommenter/__init__.py", line 42, in generate_sql_comment
    ) + '*/'
  File "/home/aaronabbott/src/.tox/py36-psycopg2/lib/python3.6/site-packages/google/cloud/sqlcommenter/__init__.py", line 41, in <genexpr>
    if value is not None
  File "/home/aaronabbott/src/.tox/py36-psycopg2/lib/python3.6/site-packages/google/cloud/sqlcommenter/__init__.py", line 46, in url_quote
    quoted = url_quote_fn(s)
  File "/usr/local/lib/python3.6/urllib/parse.py", line 825, in quote
    return quote_from_bytes(string, safe)
  File "/usr/local/lib/python3.6/urllib/parse.py", line 850, in quote_from_bytes
    raise TypeError("quote_from_bytes() expected bytes")
TypeError: quote_from_bytes() expected bytes

======================================================================
ERROR: test_libpq_version (tests.psycopg2.tests.Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/aaronabbott/src/tests/psycopg2/tests.py", line 71, in test_libpq_version
    "SELECT 1; /*libpq_version={}*/".format(url_quote(psycopg2.__libpq_version__)),
  File "/home/aaronabbott/src/.tox/py36-psycopg2/lib/python3.6/site-packages/google/cloud/sqlcommenter/__init__.py", line 46, in url_quote
    quoted = url_quote_fn(s)
  File "/usr/local/lib/python3.6/urllib/parse.py", line 825, in quote
    return quote_from_bytes(string, safe)
  File "/usr/local/lib/python3.6/urllib/parse.py", line 850, in quote_from_bytes
    raise TypeError("quote_from_bytes() expected bytes")
TypeError: quote_from_bytes() expected bytes

This skips calling the quoting function when we aren't dealing with string/bytes and tests now pass.

@aabmass aabmass marked this pull request as ready for review January 11, 2021 21:04
@aabmass aabmass changed the title fix broken tests python: fix broken tests Jan 11, 2021

@odeke-em odeke-em left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you @aabmass and happy New Year!

@odeke-em odeke-em merged commit e08044f into google:master Jan 11, 2021
@aabmass aabmass deleted the fix-py-tests branch January 11, 2021 21:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants