Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.11 compatibility #232

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 144 additions & 0 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,150 @@ jobs:
python_arch: 'x64'
tox_env: 'py310-pytest72-xdist-nocov'
os: 'macos-latest'
- name: 'py311-pytest71-nodist-cover (ubuntu)'
python: '3.11'
toxpython: 'python3.11'
python_arch: 'x64'
tox_env: 'py311-pytest71-nodist-cover,codecov'
os: 'ubuntu-latest'
- name: 'py311-pytest71-nodist-cover (windows)'
python: '3.11'
toxpython: 'python3.11'
python_arch: 'x64'
tox_env: 'py311-pytest71-nodist-cover,codecov'
os: 'windows-latest'
- name: 'py311-pytest71-nodist-cover (macos)'
python: '3.11'
toxpython: 'python3.11'
python_arch: 'x64'
tox_env: 'py311-pytest71-nodist-cover,codecov'
os: 'macos-latest'
- name: 'py311-pytest71-nodist-nocov (ubuntu)'
python: '3.11'
toxpython: 'python3.11'
python_arch: 'x64'
tox_env: 'py311-pytest71-nodist-nocov'
os: 'ubuntu-latest'
- name: 'py311-pytest71-nodist-nocov (windows)'
python: '3.11'
toxpython: 'python3.11'
python_arch: 'x64'
tox_env: 'py311-pytest71-nodist-nocov'
os: 'windows-latest'
- name: 'py311-pytest71-nodist-nocov (macos)'
python: '3.11'
toxpython: 'python3.11'
python_arch: 'x64'
tox_env: 'py311-pytest71-nodist-nocov'
os: 'macos-latest'
- name: 'py311-pytest71-xdist-cover (ubuntu)'
python: '3.11'
toxpython: 'python3.11'
python_arch: 'x64'
tox_env: 'py311-pytest71-xdist-cover,codecov'
os: 'ubuntu-latest'
- name: 'py311-pytest71-xdist-cover (windows)'
python: '3.11'
toxpython: 'python3.11'
python_arch: 'x64'
tox_env: 'py311-pytest71-xdist-cover,codecov'
os: 'windows-latest'
- name: 'py311-pytest71-xdist-cover (macos)'
python: '3.11'
toxpython: 'python3.11'
python_arch: 'x64'
tox_env: 'py311-pytest71-xdist-cover,codecov'
os: 'macos-latest'
- name: 'py311-pytest71-xdist-nocov (ubuntu)'
python: '3.11'
toxpython: 'python3.11'
python_arch: 'x64'
tox_env: 'py311-pytest71-xdist-nocov'
os: 'ubuntu-latest'
- name: 'py311-pytest71-xdist-nocov (windows)'
python: '3.11'
toxpython: 'python3.11'
python_arch: 'x64'
tox_env: 'py311-pytest71-xdist-nocov'
os: 'windows-latest'
- name: 'py311-pytest71-xdist-nocov (macos)'
python: '3.11'
toxpython: 'python3.11'
python_arch: 'x64'
tox_env: 'py311-pytest71-xdist-nocov'
os: 'macos-latest'
- name: 'py311-pytest72-nodist-cover (ubuntu)'
python: '3.11'
toxpython: 'python3.11'
python_arch: 'x64'
tox_env: 'py311-pytest72-nodist-cover,codecov'
os: 'ubuntu-latest'
- name: 'py311-pytest72-nodist-cover (windows)'
python: '3.11'
toxpython: 'python3.11'
python_arch: 'x64'
tox_env: 'py311-pytest72-nodist-cover,codecov'
os: 'windows-latest'
- name: 'py311-pytest72-nodist-cover (macos)'
python: '3.11'
toxpython: 'python3.11'
python_arch: 'x64'
tox_env: 'py311-pytest72-nodist-cover,codecov'
os: 'macos-latest'
- name: 'py311-pytest72-nodist-nocov (ubuntu)'
python: '3.11'
toxpython: 'python3.11'
python_arch: 'x64'
tox_env: 'py311-pytest72-nodist-nocov'
os: 'ubuntu-latest'
- name: 'py311-pytest72-nodist-nocov (windows)'
python: '3.11'
toxpython: 'python3.11'
python_arch: 'x64'
tox_env: 'py311-pytest72-nodist-nocov'
os: 'windows-latest'
- name: 'py311-pytest72-nodist-nocov (macos)'
python: '3.11'
toxpython: 'python3.11'
python_arch: 'x64'
tox_env: 'py311-pytest72-nodist-nocov'
os: 'macos-latest'
- name: 'py311-pytest72-xdist-cover (ubuntu)'
python: '3.11'
toxpython: 'python3.11'
python_arch: 'x64'
tox_env: 'py311-pytest72-xdist-cover,codecov'
os: 'ubuntu-latest'
- name: 'py311-pytest72-xdist-cover (windows)'
python: '3.11'
toxpython: 'python3.11'
python_arch: 'x64'
tox_env: 'py311-pytest72-xdist-cover,codecov'
os: 'windows-latest'
- name: 'py311-pytest72-xdist-cover (macos)'
python: '3.11'
toxpython: 'python3.11'
python_arch: 'x64'
tox_env: 'py311-pytest72-xdist-cover,codecov'
os: 'macos-latest'
- name: 'py311-pytest72-xdist-nocov (ubuntu)'
python: '3.11'
toxpython: 'python3.11'
python_arch: 'x64'
tox_env: 'py311-pytest72-xdist-nocov'
os: 'ubuntu-latest'
- name: 'py311-pytest72-xdist-nocov (windows)'
python: '3.11'
toxpython: 'python3.11'
python_arch: 'x64'
tox_env: 'py311-pytest72-xdist-nocov'
os: 'windows-latest'
- name: 'py311-pytest72-xdist-nocov (macos)'
python: '3.11'
toxpython: 'python3.11'
python_arch: 'x64'
tox_env: 'py311-pytest72-xdist-nocov'
os: 'macos-latest'
- name: 'pypy37-pytest71-nodist-cover (ubuntu)'
python: 'pypy-3.7'
toxpython: 'pypy3.7'
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Changelog
=========

Unreleased
----------

* Added Python 3.11 support.

4.0.0 (2022-10-26)
------------------

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def read(*names, **kwargs):
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Software Development :: Testing',
Expand Down
1 change: 1 addition & 0 deletions src/pytest_benchmark/compat.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys

PY38 = sys.version_info[0] == 3 and sys.version_info[1] >= 8
PY311 = sys.version_info[0] == 3 and sys.version_info[1] >= 11
6 changes: 5 additions & 1 deletion src/pytest_benchmark/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import genericpath

from .compat import PY38
from .compat import PY38, PY311

# This is here (in the utils module) because it might be used by
# various other modules.
Expand Down Expand Up @@ -521,6 +521,10 @@ def clonefunc(f):
co.co_firstlineno, co.co_lnotab, co.co_freevars, co.co_cellvars]
if PY38:
args.insert(1, co.co_posonlyargcount)

if PY311:
args.insert(12, co.co_qualname)
args.insert(15, co.co_exceptiontable)
co2 = types.CodeType(*args)
#
# then, we clone the function itself, using the new co2
Expand Down
1 change: 0 additions & 1 deletion tests/test_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,6 @@ def result():

" def test_bad(benchmark):",
"? @benchmark",
"? def result():",

"test_abort_broken.py:*",
"_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*",
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ envlist =
clean,
check,
docs,
{py37,py38,py39,py310,pypy37,pypy38,pypy39}-{pytest71,pytest72}-{nodist,xdist}-{cover,nocov},
{py37,py38,py39,py310,py311,pypy37,pypy38,pypy39}-{pytest71,pytest72}-{nodist,xdist}-{cover,nocov},
report
ignore_basepython_conflict = true

Expand All @@ -27,6 +27,7 @@ basepython =
py38: {env:TOXPYTHON:python3.8}
py39: {env:TOXPYTHON:python3.9}
py310: {env:TOXPYTHON:python3.10}
py311: {env:TOXPYTHON:python3.11}
{bootstrap,clean,check,report,docs,codecov,coveralls}: {env:TOXPYTHON:python3}
setenv =
PYTHONPATH={toxinidir}/tests
Expand Down