mkleehammer / pyodbc

Python ODBC bridge
https://github.com/mkleehammer/pyodbc/wiki
MIT No Attribution
2.92k stars 561 forks source link

Add tox for unit tests #1118

Closed keitherskine closed 1 year ago

keitherskine commented 1 year ago

This PR is the first in a series of PRs in an attempt to update the way the unit tests are run. This PR adds the ability to run the unit tests through tox. Tox will automatically create a virtual environment within the top-level .tox directory, and run the tests from within that venv, which is generally more convenient than creating venvs ourselves. I have tried to make as few changes as possible to the unit test scripts for this, whilst maintaining backward-compatibility with the way the unit tests are currently run in the CICD pipelines. Consequently, no changes have needed to be made to the CICD pipelines.

Tox will run the unit tests under whatever the default Python version is currently available. I have deliberately not made tox run the unit tests under multiple versions of Python. Right now, I think the use case is for developers to be able to run the unit tests quickly and easily, and one version of Python should suffice for that. The full range of Python versions will still be tested in CICD as usual. But if people feel strongly on this, I'm happy to revisit in subsequent PRs.

You'll notice I have not tried to support Python 2.7 in tox. We should be moving away from Python 2.7, and 2.7 will still be tested in CICD anyway.

Whilst here, I have updated tests3/testutils.py to not use distutils.util.get_platform() anymore because it was deprecated a long time ago and is about to be dropped.

Also, a minor couple of additions to the .pyi file.

keitherskine commented 1 year ago

Great point, Gord. I have updated run_tests().

Ref: https://tox.wiki/en/latest/index.html#system-overview, see point 3.3.