17
0

15 Commits

Author SHA256 Message Date
730d738b06 Accepting request 1301382 from devel:languages:python:pytest
OBS-URL: https://build.opensuse.org/request/show/1301382
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-pytest-examples?expand=0&rev=12
2025-08-27 19:33:47 +00:00
359404b866 - Instead of skipping the tests, add upstream ruff.patch
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:pytest/python-pytest-examples?expand=0&rev=25
2025-08-26 08:24:21 +00:00
c3bc8779c1 Accepting request 1300051 from devel:languages:python:pytest
OBS-URL: https://build.opensuse.org/request/show/1300051
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-pytest-examples?expand=0&rev=11
2025-08-18 14:08:14 +00:00
1c227bcc29 - Skip tests failing with ruff 0.12.9
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:pytest/python-pytest-examples?expand=0&rev=23
2025-08-18 11:57:49 +00:00
966a7b31a3 Accepting request 1290605 from devel:languages:python:pytest
- Update to 0.0.18:
  * adapt tests to pytest 8.3.4
  * Increase triple quote search
- Drop patch newline.patch, included upstream.
- Skip a broken test with pytest 8.4.
- Ship README and license.

OBS-URL: https://build.opensuse.org/request/show/1290605
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-pytest-examples?expand=0&rev=10
2025-07-06 15:03:34 +00:00
9a16346eea - Update to 0.0.18:
* adapt tests to pytest 8.3.4
  * Increase triple quote search
- Drop patch newline.patch, included upstream.
- Skip a broken test with pytest 8.4.
- Ship README and license.

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:pytest/python-pytest-examples?expand=0&rev=21
2025-07-04 06:13:08 +00:00
60946dbe7e Accepting request 1273219 from devel:languages:python:pytest
- update to 0.0.17:
  * Improve logic for finding print statements
  * Ensure `print_callback` runs before formatting print args
- update to 0.0.16:
  * add `include_print` config function

OBS-URL: https://build.opensuse.org/request/show/1273219
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-pytest-examples?expand=0&rev=9
2025-04-30 17:02:29 +00:00
df4ca383dd - update to 0.0.17:
* Improve logic for finding print statements
  * Ensure `print_callback` runs before formatting print args
- update to 0.0.16:
  * add `include_print` config function

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:pytest/python-pytest-examples?expand=0&rev=19
2025-04-28 16:51:46 +00:00
6e4465001d Accepting request 1238981 from devel:languages:python:pytest
OBS-URL: https://build.opensuse.org/request/show/1238981
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-pytest-examples?expand=0&rev=8
2025-01-21 20:09:43 +00:00
3d3d529566 Accepting request 1238937 from home:mcalabkova:branches:devel:languages:python:pytest
- update to 0.0.15
  * Adopt uv
  * support for calling a function/coroutine
  * Fix for single line docstrings
  * Typechecking
  * Allow matching prefix with curly braces
- add newline.patch to adapt tests to pytest 8.3.4

OBS-URL: https://build.opensuse.org/request/show/1238937
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:pytest/python-pytest-examples?expand=0&rev=17
2025-01-20 10:44:23 +00:00
161e991a8e Accepting request 1194569 from devel:languages:python:pytest
- update to 0.0.13:
  * Add new module to `sys.modules` so that namespace ops are
    sound

OBS-URL: https://build.opensuse.org/request/show/1194569
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-pytest-examples?expand=0&rev=7
2024-08-20 14:12:26 +00:00
d52dbafd94 - update to 0.0.13:
* Add new module to `sys.modules` so that namespace ops are
    sound

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:pytest/python-pytest-examples?expand=0&rev=15
2024-08-18 16:51:23 +00:00
7e4f6cb5fb Accepting request 1185172 from devel:languages:python:pytest
- update to 0.0.12:
  * Pin `ruff` version and prep for v0.0.12 release
- update to 0.0.11:
  * Use `tb_lineno` to point to correct line in traceback
  * Fix deprecation warnings in Python 3.12
  * Include tests in sdist
  * `ruff` now requires the `check` specification
- drop ruff05.patch,  fix-traceback.patch,
  support-python-312.patch, test-ruff-0.1.0.patch: upstream

- add ruff05.patch: fix exception with ruff 0.5.0

- add test-ruff-0.1.0.patch to fix tests with ruvv-0.1.0
- initial package

OBS-URL: https://build.opensuse.org/request/show/1185172
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-pytest-examples?expand=0&rev=6
2024-07-04 14:22:35 +00:00
0f17fe3296 - update to 0.0.12:
* Pin `ruff` version and prep for v0.0.12 release
- update to 0.0.11:
  * Use `tb_lineno` to point to correct line in traceback
  * Fix deprecation warnings in Python 3.12
  * Include tests in sdist
  * `ruff` now requires the `check` specification
- drop ruff05.patch,  fix-traceback.patch,
  support-python-312.patch, test-ruff-0.1.0.patch: upstream

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:pytest/python-pytest-examples?expand=0&rev=13
2024-07-03 16:14:15 +00:00
84494923c4 - add ruff05.patch: fix exception with ruff 0.5.0
- add test-ruff-0.1.0.patch to fix tests with ruvv-0.1.0
- initial package

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:pytest/python-pytest-examples?expand=0&rev=12
2024-07-01 18:03:41 +00:00
8 changed files with 161 additions and 330 deletions

View File

@@ -1,223 +0,0 @@
From 3fe64dc479d318fa58fd1952bd37ce9db2beb23f Mon Sep 17 00:00:00 2001
From: Alex Hall <alex.mojaki@gmail.com>
Date: Sun, 17 Sep 2023 17:35:21 +0200
Subject: [PATCH 1/4] Use tb_lineno to point to correct line in traceback
---
pytest_examples/traceback.py | 14 +++++++-------
tests/test_run_examples.py | 9 ++++++---
2 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/pytest_examples/traceback.py b/pytest_examples/traceback.py
index 7dedfa1..591f995 100644
--- a/pytest_examples/traceback.py
+++ b/pytest_examples/traceback.py
@@ -1,7 +1,6 @@
from __future__ import annotations as _annotations
import sys
-import traceback
from types import CodeType, FrameType, TracebackType
from typing import TYPE_CHECKING
@@ -21,16 +20,17 @@ def create_example_traceback(exc: Exception, module_path: str, example: CodeExam
# f_code.co_posonlyargcount was added in 3.8
return None
frames = []
- for frame, _ in traceback.walk_tb(exc.__traceback__):
+ tb = exc.__traceback__
+ while tb is not None:
+ frame = tb.tb_frame
if frame.f_code.co_filename == module_path:
- frames.append(create_custom_frame(frame, example))
+ frames.append((create_custom_frame(frame, example), tb.tb_lasti, tb.tb_lineno + example.start_line))
+ tb = tb.tb_next
frames.reverse()
new_tb = None
- for altered_frame in frames:
- new_tb = TracebackType(
- tb_next=new_tb, tb_frame=altered_frame, tb_lasti=altered_frame.f_lasti, tb_lineno=altered_frame.f_lineno
- )
+ for altered_frame, lasti, lineno in frames:
+ new_tb = TracebackType(tb_next=new_tb, tb_frame=altered_frame, tb_lasti=lasti, tb_lineno=lineno)
return new_tb
diff --git a/tests/test_run_examples.py b/tests/test_run_examples.py
index 6943329..9f077d7 100644
--- a/tests/test_run_examples.py
+++ b/tests/test_run_examples.py
@@ -224,7 +224,10 @@ def test_run_directly(tmp_path, eval_example):
x = 4
def div(y):
- return x / y
+ try:
+ return x / y
+ finally:
+ str(y)
div(2)
div(0)"""
@@ -244,10 +247,10 @@ def div(y):
# debug(exc_info.traceback)
assert exc_info.traceback[-1].frame.code.path == md_file
- assert exc_info.traceback[-1].lineno == 6
+ assert exc_info.traceback[-1].lineno == 7
assert exc_info.traceback[-2].frame.code.path == md_file
- assert exc_info.traceback[-2].lineno == 9
+ assert exc_info.traceback[-2].lineno == 12
def test_print_sub(pytester: pytest.Pytester):
From e07b1538df6eb662c2b92b9da9b768a2cc1f3ed3 Mon Sep 17 00:00:00 2001
From: Alex Hall <alex.mojaki@gmail.com>
Date: Sun, 17 Sep 2023 19:08:32 +0200
Subject: [PATCH 2/4] Keep the original co_firstlineno
---
pytest_examples/traceback.py | 10 ++++------
tests/test_run_examples.py | 2 +-
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/pytest_examples/traceback.py b/pytest_examples/traceback.py
index 591f995..9e797ed 100644
--- a/pytest_examples/traceback.py
+++ b/pytest_examples/traceback.py
@@ -36,12 +36,10 @@ def create_example_traceback(exc: Exception, module_path: str, example: CodeExam
def create_custom_frame(frame: FrameType, example: CodeExample) -> FrameType:
"""
- Create a new frame that mostly matches `frame` but with a filename from `example` and line number
- altered to match the example.
+ Create a new frame that mostly matches `frame` but with a filename from `example`.
Taken mostly from https://naleraphael.github.io/blog/posts/devlog_create_a_builtin_frame_object/
- With the CodeType creation inspired by https://stackoverflow.com/a/16123158/949890. However, we use
- `frame.f_lineno` for the line number instead of `f_code.co_firstlineno` as that seems to work.
+ With the CodeType creation inspired by https://stackoverflow.com/a/16123158/949890.
"""
import ctypes
@@ -77,7 +75,7 @@ def create_custom_frame(frame: FrameType, example: CodeExample) -> FrameType:
str(example.path),
f_code.co_name,
f_code.co_qualname,
- frame.f_lineno + example.start_line,
+ f_code.co_firstlineno,
f_code.co_lnotab,
f_code.co_exceptiontable,
)
@@ -95,7 +93,7 @@ def create_custom_frame(frame: FrameType, example: CodeExample) -> FrameType:
f_code.co_varnames,
str(example.path),
f_code.co_name,
- frame.f_lineno + example.start_line,
+ f_code.co_firstlineno,
f_code.co_lnotab,
)
diff --git a/tests/test_run_examples.py b/tests/test_run_examples.py
index 9f077d7..9bf3dcc 100644
--- a/tests/test_run_examples.py
+++ b/tests/test_run_examples.py
@@ -54,7 +54,7 @@ def test_find_run_examples(example: CodeExample, eval_example: EvalExample):
# assert 'my_file_9_13.py:12: AssertionError' in '\n'.join(result.outlines)
assert result.outlines[-8:-3] == [
- '',
+ ' b = 2',
'> assert a + b == 4',
'E AssertionError',
'',
From 089cf8a4f0a91a5b85108205d0f58cf603af3ac5 Mon Sep 17 00:00:00 2001
From: Alex Hall <alex.mojaki@gmail.com>
Date: Wed, 20 Sep 2023 15:46:34 +0200
Subject: [PATCH 3/4] Adjust co_firstlineno so that the pytest includes the
correct context.
---
pytest_examples/traceback.py | 8 +++++---
tests/test_run_examples.py | 6 ++++--
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/pytest_examples/traceback.py b/pytest_examples/traceback.py
index 9e797ed..94ede45 100644
--- a/pytest_examples/traceback.py
+++ b/pytest_examples/traceback.py
@@ -36,7 +36,9 @@ def create_example_traceback(exc: Exception, module_path: str, example: CodeExam
def create_custom_frame(frame: FrameType, example: CodeExample) -> FrameType:
"""
- Create a new frame that mostly matches `frame` but with a filename from `example`.
+ Create a new frame that mostly matches `frame` but with a code object that has
+ a filename from `example` and adjusted an adjusted first line number
+ so that pytest shows the correct code context in the traceback.
Taken mostly from https://naleraphael.github.io/blog/posts/devlog_create_a_builtin_frame_object/
With the CodeType creation inspired by https://stackoverflow.com/a/16123158/949890.
@@ -75,7 +77,7 @@ def create_custom_frame(frame: FrameType, example: CodeExample) -> FrameType:
str(example.path),
f_code.co_name,
f_code.co_qualname,
- f_code.co_firstlineno,
+ f_code.co_firstlineno + example.start_line,
f_code.co_lnotab,
f_code.co_exceptiontable,
)
@@ -93,7 +95,7 @@ def create_custom_frame(frame: FrameType, example: CodeExample) -> FrameType:
f_code.co_varnames,
str(example.path),
f_code.co_name,
- f_code.co_firstlineno,
+ f_code.co_firstlineno + example.start_line,
f_code.co_lnotab,
)
diff --git a/tests/test_run_examples.py b/tests/test_run_examples.py
index 9bf3dcc..ad878ea 100644
--- a/tests/test_run_examples.py
+++ b/tests/test_run_examples.py
@@ -52,8 +52,10 @@ def test_find_run_examples(example: CodeExample, eval_example: EvalExample):
result = pytester.runpytest('-p', 'no:pretty', '-v')
result.assert_outcomes(passed=1, failed=1)
- # assert 'my_file_9_13.py:12: AssertionError' in '\n'.join(result.outlines)
- assert result.outlines[-8:-3] == [
+ assert result.outlines[-11:-3] == [
+ '_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ',
+ '',
+ ' a = 1',
' b = 2',
'> assert a + b == 4',
'E AssertionError',
From e07ec3de414c00afa11a94bd136b33f77608c767 Mon Sep 17 00:00:00 2001
From: Alex Hall <alex.mojaki@gmail.com>
Date: Sat, 23 Sep 2023 12:08:07 +0200
Subject: [PATCH 4/4] Loosen testing result.outlines
---
tests/test_run_examples.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/test_run_examples.py b/tests/test_run_examples.py
index ad878ea..1dcfba1 100644
--- a/tests/test_run_examples.py
+++ b/tests/test_run_examples.py
@@ -52,8 +52,8 @@ def test_find_run_examples(example: CodeExample, eval_example: EvalExample):
result = pytester.runpytest('-p', 'no:pretty', '-v')
result.assert_outcomes(passed=1, failed=1)
- assert result.outlines[-11:-3] == [
- '_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ',
+ assert result.outlines[-11].startswith('_ _ _ _ ')
+ assert result.outlines[-10:-3] == [
'',
' a = 1',
' b = 2',

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:dce3ca92ef6ac225387e9e38cac45cf81776f01a7b69fbacff4012b62984611f
size 22058

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9a464f007f805b113677a15e2f8942ebb92d7d3eb5312e9a405d018478ec9801
size 21237

View File

@@ -1,3 +1,69 @@
-------------------------------------------------------------------
Wed Aug 20 08:20:40 UTC 2025 - Markéta Machová <mmachova@suse.com>
- Instead of skipping the tests, add upstream ruff.patch
-------------------------------------------------------------------
Mon Aug 18 11:40:41 UTC 2025 - Markéta Machová <mmachova@suse.com>
- Skip tests failing with ruff 0.12.9
-------------------------------------------------------------------
Fri Jul 4 06:12:42 UTC 2025 - Steve Kowalik <steven.kowalik@suse.com>
- Update to 0.0.18:
* adapt tests to pytest 8.3.4
* Increase triple quote search
- Drop patch newline.patch, included upstream.
- Skip a broken test with pytest 8.4.
- Ship README and license.
-------------------------------------------------------------------
Mon Apr 28 16:51:32 UTC 2025 - Dirk Müller <dmueller@suse.com>
- update to 0.0.17:
* Improve logic for finding print statements
* Ensure `print_callback` runs before formatting print args
- update to 0.0.16:
* add `include_print` config function
-------------------------------------------------------------------
Fri Jan 17 16:49:17 UTC 2025 - Markéta Machová <mmachova@suse.com>
- update to 0.0.15
* Adopt uv
* support for calling a function/coroutine
* Fix for single line docstrings
* Typechecking
* Allow matching prefix with curly braces
- add newline.patch to adapt tests to pytest 8.3.4
-------------------------------------------------------------------
Sun Aug 18 16:50:49 UTC 2024 - Dirk Müller <dmueller@suse.com>
- update to 0.0.13:
* Add new module to `sys.modules` so that namespace ops are
sound
-------------------------------------------------------------------
Wed Jul 3 16:13:14 UTC 2024 - Dirk Müller <dmueller@suse.com>
- update to 0.0.12:
* Pin `ruff` version and prep for v0.0.12 release
- update to 0.0.11:
* Use `tb_lineno` to point to correct line in traceback
* Fix deprecation warnings in Python 3.12
* Include tests in sdist
* `ruff` now requires the `check` specification
- drop ruff05.patch, fix-traceback.patch,
support-python-312.patch, test-ruff-0.1.0.patch: upstream
-------------------------------------------------------------------
Mon Jul 1 18:03:28 UTC 2024 - Dirk Müller <dmueller@suse.com>
- add ruff05.patch: fix exception with ruff 0.5.0
-------------------------------------------------------------------
Sat Mar 9 13:16:58 UTC 2024 - ecsos <ecsos@opensuse.org>
@@ -21,9 +87,9 @@ Wed Jan 24 06:44:56 UTC 2024 - Steve Kowalik <steven.kowalik@suse.com>
-------------------------------------------------------------------
Thu Oct 19 16:35:18 UTC 2023 - Ondřej Súkup <mimi.vx@gmail.com>
- add test-ruff-0.1.0.patch to fix tests with ruvv-0.1.0
- add test-ruff-0.1.0.patch to fix tests with ruvv-0.1.0
-------------------------------------------------------------------
Mon Oct 16 13:59:40 UTC 2023 - Ondřej Súkup <mimi.vx@gmail.com>
- initial package
- initial package

View File

@@ -1,7 +1,7 @@
#
# spec file for package python-pytest-examples
#
# Copyright (c) 2024 SUSE LLC
# Copyright (c) 2025 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -18,19 +18,14 @@
%{?sle15_python_module_pythons}
Name: python-pytest-examples
Version: 0.0.10
Version: 0.0.18
Release: 0
Summary: Pytest plugin for testing examples in docstrings and markdown files
License: MIT
URL: https://github.com/pydantic/pytest-examples
# sdist without tests
Source: https://github.com/pydantic/pytest-examples/archive/refs/tags/v%{version}.tar.gz#/pytest-examples-%{version}.tar.gz
# PATCH-FIX-UPSTREAM gh#pydantic/pytest-examples#17
Patch0: fix-traceback.patch
# PATCH-FIX-UPSTREAM test-ruff-0.1.0.patch - fix tests for ruff-0.1.0
Patch1: test-ruff-0.1.0.patch
# PATCH-FIX-UPSTREAM gh#pydantic/pytest-examples#22
Patch2: support-python-312.patch
Source: https://files.pythonhosted.org/packages/source/p/pytest-examples/pytest_examples-%{version}.tar.gz
# PATCH-FIX-UPSTREAM https://github.com/pydantic/pytest-examples/pull/65 Bump Ruff to 0.12.9, update regexes for new output rendering
Patch0: ruff.patch
BuildRequires: %{python_module black}
BuildRequires: %{python_module hatchling}
BuildRequires: %{python_module pip}
@@ -55,7 +50,7 @@ Pytest plugin for testing Python code examples in docstrings and markdown files.
It can also update code examples in place to format them and insert or update print statements.
%prep
%autosetup -p1 -n pytest-examples-%{version}
%autosetup -p1 -n pytest_examples-%{version}
%build
%pyproject_wheel
@@ -65,9 +60,11 @@ It can also update code examples in place to format them and insert or update pr
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
%pytest
%pytest -k 'not test_run_example_ok_fail'
%files %{python_files}
%license LICENSE
%doc README.md
%{python_sitelib}/pytest_examples
%{python_sitelib}/pytest_examples-%{version}.dist-info

81
ruff.patch Normal file
View File

@@ -0,0 +1,81 @@
From 60ae70d05ee345b38c2d2048d36b4a4545c98b6b Mon Sep 17 00:00:00 2001
From: Brent Westbrook <brentrwestbrook@gmail.com>
Date: Mon, 18 Aug 2025 13:36:21 -0400
Subject: [PATCH] Bump Ruff to 0.12.9, update regexes for new output rendering
Ruff 0.12.9 updated our default `full` output rendering to split the
header (`filename:line:column error`) over two lines, which was causing a few
test failures. This PR bumps the Ruff dependency to `>=0.12.9` and updates the
regular expressions affecting the failing tests to expect the new format.
See https://github.com/astral-sh/ruff/issues/19966 for more details.
---
pyproject.toml | 2 +-
pytest_examples/lint.py | 4 ++--
tests/test_lint.py | 4 ++--
tests/test_run_examples.py | 4 ++--
uv.lock | 43 +++++++++++++++++++-------------------
5 files changed, 29 insertions(+), 28 deletions(-)
diff --git a/pyproject.toml b/pyproject.toml
index d630714..168de4f 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -34,7 +34,7 @@ classifiers = [
"Topic :: Software Development :: Libraries :: Python Modules",
]
requires-python = ">=3.8"
-dependencies = ["pytest>=7", "black>=23", "ruff>=0.5.0"]
+dependencies = ["pytest>=7", "black>=23", "ruff>=0.12.9"]
[project.entry-points.pytest11]
examples = "pytest_examples"
diff --git a/pytest_examples/lint.py b/pytest_examples/lint.py
index 67133d4..17b6cb4 100644
--- a/pytest_examples/lint.py
+++ b/pytest_examples/lint.py
@@ -57,9 +57,9 @@ def ruff_check(
def replace_offset(m: re.Match[str]):
line_number = int(m.group(1))
- return f'{example.path}:{line_number + example.start_line}'
+ return f' --> {example.path}:{line_number + example.start_line}'
- output = re.sub(r'^-:(\d+)', replace_offset, stdout, flags=re.M)
+ output = re.sub(r'^ --> -:(\d+)', replace_offset, stdout, flags=re.M)
raise FormatError(f'ruff failed:\n{indent(output, " ")}')
elif p.returncode != 0:
raise RuntimeError(f'Error running ruff, return code {p.returncode}:\n{stderr or stdout}')
diff --git a/tests/test_lint.py b/tests/test_lint.py
index b735bb1..cfc67ed 100644
--- a/tests/test_lint.py
+++ b/tests/test_lint.py
@@ -24,11 +24,11 @@ def test_ruff_config():
def test_ruff_offset():
code = 'print(x)\n'
example = CodeExample.create(code)
- with pytest.raises(FormatError, match='testing.md:1:7: F821 Undefined name'):
+ with pytest.raises(FormatError, match='F821 Undefined name `x`\n --> testing.md:1:7'):
ruff_check(example, ExamplesConfig())
example = CodeExample.create(code, start_line=10)
- with pytest.raises(FormatError, match='testing.md:11:7: F821 Undefined name'):
+ with pytest.raises(FormatError, match='F821 Undefined name `x`\n --> testing.md:11:7'):
ruff_check(example, ExamplesConfig())
diff --git a/tests/test_run_examples.py b/tests/test_run_examples.py
index d9df4b2..53958cc 100644
--- a/tests/test_run_examples.py
+++ b/tests/test_run_examples.py
@@ -111,8 +111,8 @@ def test_find_run_examples(example: CodeExample, eval_example: EvalExample):
'=== FAILURES ===\n',
'___ test_find_run_examples[my_file.md:1-4] ___\n',
'ruff failed:\n',
- ' my_file.md:2:8: F401 [*] `sys` imported but unused\n',
- ' my_file.md:3:7: F821 Undefined name `missing`\n',
+ ' F401 [*] `sys` imported but unused\n --> my_file.md:2:8\n',
+ ' F821 Undefined name `missing`\n --> my_file.md:3:7\n',
' Found 2 errors.\n',
' [*] 1 fixable with the `--fix` option.\n',
'=== short test summary info ===\n',

View File

@@ -1,68 +0,0 @@
From 35f93d668c8a4a337d1c9d477fa5732fa439b1b3 Mon Sep 17 00:00:00 2001
From: Alex Hall <alex.mojaki@gmail.com>
Date: Wed, 27 Sep 2023 17:47:51 +0200
Subject: [PATCH 1/2] Fix deprecation warnings in Python 3.12
---
.github/workflows/ci.yml | 2 +-
pytest_examples/traceback.py | 21 ++++++++++++++++++++-
requirements/testing.txt | 6 ++----
3 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/pytest_examples/traceback.py b/pytest_examples/traceback.py
index 94ede45..41880fe 100644
--- a/pytest_examples/traceback.py
+++ b/pytest_examples/traceback.py
@@ -62,7 +62,26 @@ def create_custom_frame(frame: FrameType, example: CodeExample) -> FrameType:
ctypes.pythonapi.PyThreadState_Get.restype = P_MEM_TYPE
f_code = frame.f_code
- if sys.version_info >= (3, 11):
+ if sys.version_info >= (3, 12):
+ code = CodeType(
+ f_code.co_argcount,
+ f_code.co_posonlyargcount,
+ f_code.co_kwonlyargcount,
+ f_code.co_nlocals,
+ f_code.co_stacksize,
+ f_code.co_flags,
+ f_code.co_code,
+ f_code.co_consts,
+ f_code.co_names,
+ f_code.co_varnames,
+ str(example.path),
+ f_code.co_name,
+ f_code.co_qualname,
+ f_code.co_firstlineno + example.start_line,
+ f_code.co_linetable,
+ f_code.co_exceptiontable,
+ )
+ elif sys.version_info >= (3, 11):
code = CodeType(
f_code.co_argcount,
f_code.co_posonlyargcount,
diff --git a/requirements/testing.txt b/requirements/testing.txt
index 805175d..4b42722 100644
--- a/requirements/testing.txt
+++ b/requirements/testing.txt
@@ -2,10 +2,8 @@
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
-# pip-compile --output-file=requirements/testing.txt --resolver=backtracking requirements/testing.in
+# pip-compile --output-file=requirements/testing.txt requirements/testing.in
#
-attrs==22.2.0
- # via pytest
coverage==7.2.2
# via -r requirements/testing.in
exceptiongroup==1.1.1
@@ -22,7 +20,7 @@ pluggy==1.0.0
# via pytest
pygments==2.14.0
# via rich
-pytest==7.2.2
+pytest==7.4.2
# via pytest-pretty
pytest-pretty==1.1.1
# via -r requirements/testing.in

View File

@@ -1,22 +0,0 @@
From cade1306918e9984d0d45d5e274d01b734b5fd3a Mon Sep 17 00:00:00 2001
From: Anton Zhukharev <ancieg@altlinux.org>
Date: Wed, 18 Oct 2023 09:38:34 +0300
Subject: [PATCH] update tests for ruff>=0.1.0
---
tests/test_run_examples.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/test_run_examples.py b/tests/test_run_examples.py
index 1dcfba1..4330d71 100644
--- a/tests/test_run_examples.py
+++ b/tests/test_run_examples.py
@@ -114,7 +114,7 @@ def test_find_run_examples(example: CodeExample, eval_example: EvalExample):
' my_file.md:2:8: F401 [*] `sys` imported but unused\n'
' my_file.md:3:7: F821 Undefined name `missing`\n'
' Found 2 errors.\n'
- ' [*] 1 potentially fixable with the --fix option.\n'
+ ' [*] 1 fixable with the `--fix` option.\n'
'=== short test summary info ===\n'
) in output