Skip to content

Commit

Permalink
Support Python 3.12 and pytest 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito committed Feb 10, 2024
1 parent 2fd2c21 commit 6477a61
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 34 deletions.
26 changes: 17 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

strategy:
matrix:
python: ['3.7', '3.8', '3.9', '3.10', '3.11', 'pypy3.9']
python: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', 'pypy3.9', 'pypy3.10']

steps:
- uses: actions/checkout@v3
Expand All @@ -36,34 +36,42 @@ jobs:
- name: Test with Python 3.7
if: matrix.python == '3.7'
run: tox run -x "tox.envlist=py37-pytest{4,5,60,61,62,70,71,72,73}"
run: tox run -x "tox.envlist=py37-pytest{4,5,60,61,62,70,71,72,73,74}"

- name: Test with Python 3.8
if: matrix.python == '3.8'
run: tox run -x "tox.envlist=py38-pytest{4,5,60,61,62,70,71,72,73}"
run: tox run -x "tox.envlist=py38-pytest{4,5,60,61,62,70,71,72,73,74,80}"

- name: Test with Python 3.9
if: matrix.python == '3.9'
run: tox run -x "tox.envlist=py39-pytest{4,5,60,61,62,70,71,72,73}"
run: tox run -x "tox.envlist=py39-pytest{4,5,60,61,62,70,71,72,73,74,80}"

- name: Test with Python 3.10
if: matrix.python == '3.10'
run: tox run -x "tox.envlist=py310-pytest{62,70,71,72,73}"
run: tox run -x "tox.envlist=py310-pytest{70,71,72,73,74,80}"

- name: Test with Python 3.11
if: matrix.python == '3.11'
run: tox run -x "tox.envlist=spy311-pytest{73}"
run: tox run -x "tox.envlist=spy311-pytest{73,74,80}"

- name: Test with Python 3.12
if: matrix.python == '3.12'
run: tox run -x "tox.envlist=spy312-pytest{74,80}"

- name: Test with PyPy 3.9
if: matrix.python == 'pypy3.9'
run: tox run -x "tox.envlist=pypy39-pytest{4,5,60,61,62,70,71,72,73}"
run: tox run -x "tox.envlist=pypy39-pytest{4,5,60,61,62,70,71,72,73,74}"

- name: Test with PyPy 3.10
if: matrix.python == 'pypy3.10'
run: tox run -x "tox.envlist=pypy310-pytest{70,71,72,73,74,80}"

- name: Linting with Flake8
if: matrix.python == '3.10'
if: matrix.python == '3.11'
run: tox run -e flake8

- name: Ensure full coverage
if: matrix.python == '3.10'
if: matrix.python == '3.11'
run: tox run -e coverage

deploy:
Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ classifiers =
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Topic :: Software Development :: Libraries
Topic :: Software Development :: Testing
Topic :: Utilities
Expand All @@ -39,7 +40,7 @@ python_requires = >=3.7
packages =
pytest_describe
install_requires =
pytest>=4.6,<8
pytest>=4.6,<9

[options.entry_points]
pytest11 =
Expand Down
26 changes: 14 additions & 12 deletions test/test_collect.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Test collection of test functions"""

from textwrap import dedent


def test_collect_only(testdir):
testdir.makepyfile(
Expand All @@ -24,18 +26,18 @@ def test_something():
result = testdir.runpytest('--collectonly')
result.assert_outcomes()

output = '\n'.join(filter(None, result.outlines))
assert """
collected 4 items
<Module test_collect_only.py>
<DescribeBlock 'describe_something'>
<Function is_foo>
<Function can_bar>
<DescribeBlock 'describe_something_else'>
<DescribeBlock 'describe_nested'>
<Function a_test>
<Function test_something>
""" in output
output = '\n'.join(line.lstrip() for line in result.outlines)
assert "collected 4 items" in output
assert dedent("""
<Module test_collect_only.py>
<DescribeBlock 'describe_something'>
<Function is_foo>
<Function can_bar>
<DescribeBlock 'describe_something_else'>
<DescribeBlock 'describe_nested'>
<Function a_test>
<Function test_something>
""") in output


def test_describe_evaluated_once(testdir):
Expand Down
18 changes: 10 additions & 8 deletions test/test_prefix.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Test custom prefixes"""

from textwrap import dedent


def test_collect_custom_prefix(testdir):
testdir.makeini(
Expand All @@ -19,11 +21,11 @@ def passes():
result = testdir.runpytest('--collectonly')
result.assert_outcomes()

output = '\n'.join(filter(None, result.outlines))
assert """
collected 1 item
<Module test_collect_custom_prefix.py>
<DescribeBlock 'foo_scope'>
<DescribeBlock 'bar_context'>
<Function passes>
""" in output
output = '\n'.join(line.lstrip() for line in result.outlines if line)
assert "collected 1 item" in output
assert dedent("""
<Module test_collect_custom_prefix.py>
<DescribeBlock 'foo_scope'>
<DescribeBlock 'bar_context'>
<Function passes>
""") in output
12 changes: 8 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py{37,38,39,py39}-pytest{4,5,60,61,62,70,71,72,73},py310-pytest{62,70,71,72,73},py311-pytest{73,-latest},flake8,coverage
envlist = py37-pytest{4,5,60,61,62,70,71,72,73,74},py{38,39,py39}-pytest{4,5,60,61,62,70,71,72,73,74,80},py{310,py310}-pytest{70,71,72,73,74,80},py311-pytest{73,74,80,-latest},py312-pytest{74,80,-latest},flake8,coverage

[testenv]
basepython =
Expand All @@ -8,7 +8,9 @@ basepython =
py39: python3.9
py310: python3.10
py311: python3.11
py312: python3.12
pypy39: pypy3.9
pypy310: pypy3.10
deps =
pytest4: pytest>=4.6,<5.0
pytest5: pytest>=5.4,<5.5
Expand All @@ -19,18 +21,20 @@ deps =
pytest71: pytest>=7.1,<7.2
pytest72: pytest>=7.2,<7.3
pytest73: pytest>=7.3,<7.4
pytest74: pytest>=7.4,<7.5
pytest80: pytest>=8.0,<8.1
pytest-latest: pytest
pytest-main: git+https://github.com/pytest-dev/pytest.git@main
commands = pytest test {posargs}

[testenv:flake8]
basepython = python3.10
deps = flake8>=6,<7
basepython = python3.11
deps = flake8>=7,<8
commands =
flake8 pytest_describe test setup.py

[testenv:coverage]
basepython = python3.10
basepython = python3.11
deps =
coverage
pytest
Expand Down

0 comments on commit 6477a61

Please sign in to comment.