Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-executing for
openSUSE:Factory checked in at 2025-01-20 17:14:03
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-executing (Old)
and /work/SRC/openSUSE:Factory/.python-executing.new.5589 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-executing"
Mon Jan 20 17:14:03 2025 rev:13 rq:1238543 version:2.1.0
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-executing/python-executing.changes
2024-10-23 21:08:21.633913986 +0200
+++
/work/SRC/openSUSE:Factory/.python-executing.new.5589/python-executing.changes
2025-01-20 17:14:08.161111285 +0100
@@ -1,0 +2,5 @@
+Fri Jan 17 16:19:38 UTC 2025 - Markéta Machová <[email protected]>
+
+- Add pytest.patch to fix compatibility with new pytest
+
+-------------------------------------------------------------------
New:
----
pytest.patch
BETA DEBUG BEGIN:
New:
- Add pytest.patch to fix compatibility with new pytest
BETA DEBUG END:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-executing.spec ++++++
--- /var/tmp/diff_new_pack.kbWQaw/_old 2025-01-20 17:14:08.689133022 +0100
+++ /var/tmp/diff_new_pack.kbWQaw/_new 2025-01-20 17:14:08.689133022 +0100
@@ -1,7 +1,7 @@
#
# spec file for package python-executing
#
-# 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
@@ -34,6 +34,8 @@
Source:
https://files.pythonhosted.org/packages/source/e/executing/executing-%{version}.tar.gz
# PATCH-FIX-UPSTREAM https://github.com/alexmojaki/executing/pull/86 fix:
backward compatibility fix for changed source positions in 3.12.6
Patch0: new-python-312.patch
+# PATCH-FIX-UPSTREAM https://github.com/alexmojaki/executing/pull/94 fix:
check for pytest compatibility
+Patch1: pytest.patch
BuildRequires: %{python_module devel}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module setuptools_scm >= 4.0.0}
++++++ pytest.patch ++++++
>From 0edb6ca3d733d8cb3fd1ddc7994bde61991ac4c2 Mon Sep 17 00:00:00 2001
From: Frank Hoffmann <[email protected]>
Date: Sun, 12 Jan 2025 17:03:09 +0100
Subject: [PATCH] fix: check for pytest compatibility (#94)
---
executing/__init__.py | 5 ++++-
executing/_pytest_utils.py | 16 ++++++++++++++++
tests/conftest.py | 25 +++++++++++++++++++++++++
tests/test_main.py | 5 -----
tests/test_pytest.py | 5 +++++
5 files changed, 50 insertions(+), 6 deletions(-)
create mode 100644 executing/_pytest_utils.py
create mode 100644 tests/conftest.py
diff --git a/executing/__init__.py b/executing/__init__.py
index b645197..e5181a5 100644
--- a/executing/__init__.py
+++ b/executing/__init__.py
@@ -10,6 +10,9 @@
from collections import namedtuple
_VersionInfo = namedtuple('_VersionInfo', ('major', 'minor', 'micro'))
from .executing import Source, Executing, only, NotOneValueFound, cache,
future_flags
+
+from ._pytest_utils import is_pytest_compatible
+
try:
from .version import __version__ # type: ignore[import]
if "dev" in __version__:
@@ -22,4 +25,4 @@
__version_info__ = _VersionInfo(*map(int, __version__.split('.')))
-__all__ = ["Source"]
+__all__ = ["Source","is_pytest_compatible"]
diff --git a/executing/_pytest_utils.py b/executing/_pytest_utils.py
new file mode 100644
index 0000000..fab8693
--- /dev/null
+++ b/executing/_pytest_utils.py
@@ -0,0 +1,16 @@
+import sys
+
+
+
+def is_pytest_compatible() -> bool:
+ """ returns true if executing can be used for expressions inside assert
statements which are rewritten by pytest
+ """
+ if sys.version_info < (3, 11):
+ return False
+
+ try:
+ import pytest
+ except ImportError:
+ return False
+
+ return pytest.version_tuple >= (8, 3, 4)
diff --git a/tests/conftest.py b/tests/conftest.py
new file mode 100644
index 0000000..5108348
--- /dev/null
+++ b/tests/conftest.py
@@ -0,0 +1,25 @@
+
+
+from typing import Optional, Sequence, Union
+from executing._pytest_utils import is_pytest_compatible
+import _pytest.assertion.rewrite as rewrite
+import importlib.machinery
+import types
+
+if not is_pytest_compatible():
+ original_find_spec = rewrite.AssertionRewritingHook.find_spec
+
+
+ def find_spec(
+ self,
+ name: str,
+ path: Optional[Sequence[Union[str, bytes]]] = None,
+ target: Optional[types.ModuleType] = None,
+ ) -> Optional[importlib.machinery.ModuleSpec]:
+
+ if name == "tests.test_main":
+ return None
+ return original_find_spec(self, name, path, target)
+
+
+ rewrite.AssertionRewritingHook.find_spec = find_spec
diff --git a/tests/test_main.py b/tests/test_main.py
index a3f92ee..e3bc9d6 100644
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -1,9 +1,4 @@
# -*- coding: utf-8 -*-
-"""
-
-assert rewriting will break executing
-PYTEST_DONT_REWRITE
-"""
from __future__ import print_function, division
import ast
import contextlib
diff --git a/tests/test_pytest.py b/tests/test_pytest.py
index 281598d..5cbe0a2 100644
--- a/tests/test_pytest.py
+++ b/tests/test_pytest.py
@@ -6,6 +6,7 @@
from time import sleep
import asttokens
+from executing._pytest_utils import is_pytest_compatible
import pytest
from littleutils import SimpleNamespace
@@ -124,6 +125,10 @@ def check_manual_linecache(filename):
def test_exception_catching():
frame = inspect.currentframe()
+ if is_pytest_compatible():
+ assert isinstance(Source.executing(frame).node,ast.Call)
+ return
+
executing.executing.TESTING = True # this is already the case in all
other tests
# Sanity check that this operation usually raises an exception.
# This actually depends on executing not working in the presence of pytest.