jazzband / geojson

Python bindings and utilities for GeoJSON
https://pypi.python.org/pypi/geojson/
BSD 3-Clause "New" or "Revised" License
913 stars 121 forks source link

Fix tests and don't invoke setup.py directly #215

Closed hugovk closed 1 year ago

hugovk commented 1 year ago

The merge of https://github.com/jazzband/geojson/pull/211 failed the CI for Python 3.12:

https://github.com/jazzband/geojson/actions/runs/5098872321/jobs/9166263747

Run coverage run --branch --source=geojson setup.py test
Traceback (most recent call last):
  File "/home/runner/work/geojson/geojson/setup.py", line 1, in <module>
    from setuptools import setup
ModuleNotFoundError: No module named 'setuptools'

That's because the 3.12 beta removed setuptools from Python. We could install setuptools on the CI, but really we shouldn't be running tests via python setup.py test - we shouldn't invoke setup.py directly. See https://blog.ganssle.io/tag/setuptools.html for the long version.

Instead, let's modernise testing and use pytest and tox to run the tests.

So for example, tests can be run like:

python -m pip install pytest
pytest

Or with tox on all available Python versions:

python -m pip install tox
tox

Or a specific version:

tox -e py312

Or all in parallel:

tox -p auto
codecov[bot] commented 1 year ago

Codecov Report

Merging #215 (b2d9166) into main (dbd83d8) will increase coverage by 0.51%. The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #215      +/-   ##
==========================================
+ Coverage   97.73%   98.25%   +0.51%     
==========================================
  Files          10       19       +9     
  Lines         353      801     +448     
  Branches       76        0      -76     
==========================================
+ Hits          345      787     +442     
- Misses          5       14       +9     
+ Partials        3        0       -3     

see 14 files with indirect coverage changes

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more