Skip to content

Commit

Permalink
Test via tox and pytest for Python 3.12 compatibility (#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed May 27, 2023
1 parent dbd83d8 commit 3a3a1b3
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 26 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 7
fail-fast: false
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12-dev', 'pypy-3.8']
python-version: ['pypy3.9', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v3
Expand All @@ -20,18 +20,18 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
cache: pip
cache-dependency-path: setup.py
cache-dependency-path: tox.ini

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade coverage
python -m pip install --upgrade tox
- name: Tests
run: |
coverage run --branch --source=geojson setup.py test
coverage xml
tox -e py
- name: Upload coverage
uses: codecov/codecov-action@v3
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ sdist/
*.egg-info/
*.egg
.tox/
.coverage
coverage.xml
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-case-conflict
- id: check-merge-conflict
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/tox-dev/tox-ini-fmt
rev: 1.3.0
hooks:
- id: tox-ini-fmt

ci:
autoupdate_schedule: quarterly
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ coordinates to 6 decimal places (roughly 0.1 meters) by default and can be custo
{"coordinates": [-115.12341234, 37.12341234], "type": "Point"}
Precision can be set at the package level by setting `geojson.geometry.DEFAULT_PRECISION`
Precision can be set at the package level by setting `geojson.geometry.DEFAULT_PRECISION`


.. code:: python
Expand Down Expand Up @@ -410,7 +410,7 @@ Development
-----------

To build this project, run :code:`python setup.py build`.
To run the unit tests, run :code:`python setup.py test`.
To run the unit tests, run :code:`python -m pip install tox && tox`.
To run the style checks, run :code:`flake8` (install `flake8` if needed).

Credits
Expand Down
10 changes: 0 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@
raise RuntimeError(f"Unable to find version string in {VERSIONFILE}.")


def test_suite():
import doctest
import unittest

suite = unittest.TestLoader().discover("tests")
suite.addTest(doctest.DocFileSuite("README.rst"))
return suite


major_version, minor_version = sys.version_info[:2]
if not (major_version == 3 and 7 <= minor_version <= 12):
sys.stderr.write("Sorry, only Python 3.7 - 3.12 are "
Expand All @@ -47,7 +38,6 @@ def test_suite():
package_dir={"geojson": "geojson"},
package_data={"geojson": ["*.rst"]},
install_requires=[],
test_suite="setup.test_suite",
python_requires=">=3.7",
classifiers=[
"Development Status :: 5 - Production/Stable",
Expand Down
2 changes: 1 addition & 1 deletion tests/data.geojson
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"properties": {
"Ã": "Ã"
},
},
"type": "Feature",
"geometry": null
}
18 changes: 11 additions & 7 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Tox (http://tox.testrun.org/) is a tool for running tests
# in multiple virtualenvs. This configuration file will run the
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.

[tox]
envlist = py{py3, 312, 311, 310, 39, 38, 37}
requires =
tox>=4.2
env_list =
py{py3, 312, 311, 310, 39, 38, 37}

[testenv]
commands = {envpython} setup.py test
deps =
pytest
pytest-cov
pass_env =
FORCE_COLOR
commands =
{envpython} -m pytest --cov geojson --cov tests --cov-report xml {posargs}

0 comments on commit 3a3a1b3

Please sign in to comment.