17
0

9 Commits

Author SHA256 Message Date
63b6564ecd 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
abca5b9c2d - 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
799b6587de 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
dbf93cc5c4 - 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/package/show/devel:languages:python:pytest/python-pytest-examples?expand=0&rev=17
2025-01-20 10:44:23 +00:00
11071fc436 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
eacb77b103 - 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
4ae8e191c0 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
52ff62d5a1 - 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
d2acbce250 - 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
6 changed files with 36 additions and 110 deletions

28
newline.patch Normal file
View File

@@ -0,0 +1,28 @@
Index: pytest_examples-0.0.15/tests/test_run_examples.py
===================================================================
--- pytest_examples-0.0.15.orig/tests/test_run_examples.py
+++ pytest_examples-0.0.15/tests/test_run_examples.py
@@ -171,6 +171,7 @@ def test_find_run_examples(example: Code
'@@ -4 +4 @@',
'-x =[1,2, 3]',
'+x = [1, 2, 3]',
+ '',
]
@@ -205,6 +206,7 @@ def test_find_run_examples(example: Code
'@@ -4 +4 @@',
'-x·=[1,2,·3]',
'+x·=·[1,·2,·3]',
+ '',
]
@@ -251,6 +253,7 @@ def test_find_run_examples(example: Code
'- 3',
'-]',
'+x = [1, 2, 3]',
+ '',
]

BIN
pytest_examples-0.0.17.tar.gz LFS Normal file

Binary file not shown.

View File

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

View File

@@ -1,23 +1,3 @@
-------------------------------------------------------------------
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>

View File

@@ -18,14 +18,15 @@
%{?sle15_python_module_pythons}
Name: python-pytest-examples
Version: 0.0.18
Version: 0.0.17
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://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
# PATCH-FIX-UPSTREAM https://github.com/pydantic/pytest-examples/pull/54 adapt tests to pytest 8.3.4
Patch: newline.patch
BuildRequires: %{python_module black}
BuildRequires: %{python_module hatchling}
BuildRequires: %{python_module pip}
@@ -60,11 +61,9 @@ It can also update code examples in place to format them and insert or update pr
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
%pytest -k 'not test_run_example_ok_fail'
%pytest
%files %{python_files}
%license LICENSE
%doc README.md
%{python_sitelib}/pytest_examples
%{python_sitelib}/pytest_examples-%{version}.dist-info

View File

@@ -1,81 +0,0 @@
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',