Skip to content

Commit

Permalink
Switch to pytest and other version updates
Browse files Browse the repository at this point in the history
- Switch to using pytest
- Update python versions
- Update dependency versions
  • Loading branch information
markpeek committed Jan 22, 2025
1 parent 8aaed1d commit eb68efa
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 38 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ jobs:
fail-fast: false
matrix:
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"

steps:
- uses: actions/checkout@v3
Expand All @@ -42,7 +42,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.7
python-version: 3.13
- name: Install dependencies
run: |
python -m pip install --upgrade pip tox
Expand All @@ -56,7 +56,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: 3.13
- name: Install dependencies
run: |
python -m pip install --upgrade pip tox
Expand Down
4 changes: 1 addition & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ project_urls =

[options]
include_package_data = true
install_requires =
typing-extensions >= 3.7.4.3; python_version < "3.8"
packages = find:
python_requires = >=3.7.0
python_requires = >=3.9
zip_safe = false

[options.packages.find]
Expand Down
30 changes: 4 additions & 26 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import glob
import os
import re
import pytest
import sys
import unittest
from functools import partial


class TestExamples(unittest.TestCase):
pass
files = glob.glob(os.path.join("examples", "*.py"))


@pytest.mark.parametrize("filename", files)
def test_file(filename):
# Ignore the output
saved = sys.stdout
Expand All @@ -20,24 +19,3 @@ def test_file(filename):
exec(code)
finally:
sys.stdout = saved


def add_tests():
# Filter out all *.py files from the examples directory
examples = "examples"
regex = re.compile(r".py$", re.I)
example_filesnames = filter(regex.search, os.listdir(examples))

# Add new test functions to the TestExamples class
for f in example_filesnames:
testname = "test_" + f[:-3]
testfunc = partial(test_file, examples + "/" + f)
# Get rid of partial() __doc__
testfunc.__doc__ = None
setattr(TestExamples, testname, testfunc)


add_tests()

if __name__ == "__main__":
unittest.main()
12 changes: 7 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
[tox]
envlist =
py{36,37,38,39,310,311}
py{39,310,311,312,313}
qa,package

[testenv]
commands = python -W error::PendingDeprecationWarning setup.py test {posargs}
deps =
pytest
commands = pytest tests {posargs}

[testenv:mypy]
deps =
Expand All @@ -23,9 +25,9 @@ commands =

[testenv:package]
deps =
build>=0.3.1
check_manifest>=0.46
twine>=3.4.1
build>=1.2.2
check_manifest>=0.50
twine>=6.1.0
commands =
python -m check_manifest
python -m build --sdist --wheel .
Expand Down

0 comments on commit eb68efa

Please sign in to comment.