Skip to content

Ensure pytest imports local mysql.connector sources - #110

Open
crmpicco wants to merge 1 commit into
mysql:trunkfrom
crmpicco:trunk
Open

crmpicco wants to merge 1 commit into
mysql:trunkfrom
crmpicco:trunk

Conversation

@crmpicco

@crmpicco crmpicco commented Oct 15, 2026 •

Copy link
Copy Markdown

Summary

Fix pytest imports so the test suite uses the local source tree from this fork instead of an installed mysql-connector-python package from site-packages.

This prevents unrelated warnings from the installed wheel from appearing during test runs and makes the tests exercise the code in this repository.

Changes

  • Added a root conftest.py to prepend:
    • mysql-connector-python/lib
    • mysqlx-connector-python/lib
      to sys.path
  • Added a regression test to verify mysql.connector is imported from the repo tree

Why

Running pytest was picking up the installed package version, which emitted SyntaxWarnings from outside the forked source tree. With the repo-local path first, tests now target the code under development.

Verification

  • Confirmed mysql.connector.__file__ resolves to the local repo checkout
  • Syntax-checked the added files with py_compile

Notes

This change only affects test/import resolution; it does not modify runtime package behaviour.

The following error was observed during a PyTest test suite run:

=============================== warnings summary ===============================
pytest-venv/lib/python3.12/site-packages/mysql/connector/abstracts.py:130
  /builds/hosting/crmpicco/pytest-venv/lib/python3.12/site-packages/mysql/connector/abstracts.py:130: SyntaxWarning: "is" with 'str' literal. Did you mean "=="?
    if group is 'connector_python':
pytest-venv/lib/python3.12/site-packages/mysql/connector/optionfiles.py:98
  /builds/hosting/crmpicco/pytest-venv/lib/python3.12/site-packages/mysql/connector/optionfiles.py:98: SyntaxWarning: "is" with 'str' literal. Did you mean "=="?
    if group is 'connector_python':
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

Fix pytest imports so the test suite uses the local source tree from this fork instead of an installed mysql-connector-python package from site-packages
@mysql-oca-bot

Copy link
Copy Markdown

Hi, thank you for submitting this pull request. In order to consider your code we need you to sign the Oracle Contribution Agreement (OCA). Please review the details and follow the instructions at https://oca.opensource.oracle.com/
Please make sure to include your MySQL bug system user (email) in the returned form.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants