Accepting request 942999 from devel:languages:python:pytest
OBS-URL: https://build.opensuse.org/request/show/942999 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-pytest?expand=0&rev=68
This commit is contained in:
commit
6249854fd0
83
pytest-pr9173-importlib-py310.patch
Normal file
83
pytest-pr9173-importlib-py310.patch
Normal file
@ -0,0 +1,83 @@
|
||||
Index: pytest-6.2.5/changelog/9169.bugfix.rst
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ pytest-6.2.5/changelog/9169.bugfix.rst
|
||||
@@ -0,0 +1 @@
|
||||
+Support for the ``files`` API from ``importlib.resources`` within rewritten files.
|
||||
Index: pytest-6.2.5/src/_pytest/assertion/rewrite.py
|
||||
===================================================================
|
||||
--- pytest-6.2.5.orig/src/_pytest/assertion/rewrite.py
|
||||
+++ pytest-6.2.5/src/_pytest/assertion/rewrite.py
|
||||
@@ -63,7 +63,7 @@ class AssertionRewritingHook(importlib.a
|
||||
except ValueError:
|
||||
self.fnpats = ["test_*.py", "*_test.py"]
|
||||
self.session: Optional[Session] = None
|
||||
- self._rewritten_names: Set[str] = set()
|
||||
+ self._rewritten_names: Dict[str, Path] = {}
|
||||
self._must_rewrite: Set[str] = set()
|
||||
# flag to guard against trying to rewrite a pyc file while we are already writing another pyc file,
|
||||
# which might result in infinite recursion (#3506)
|
||||
@@ -133,7 +133,7 @@ class AssertionRewritingHook(importlib.a
|
||||
fn = Path(module.__spec__.origin)
|
||||
state = self.config._store[assertstate_key]
|
||||
|
||||
- self._rewritten_names.add(module.__name__)
|
||||
+ self._rewritten_names[module.__name__] = fn
|
||||
|
||||
# The requested module looks like a test file, so rewrite it. This is
|
||||
# the most magical part of the process: load the source, rewrite the
|
||||
@@ -275,6 +275,14 @@ class AssertionRewritingHook(importlib.a
|
||||
with open(pathname, "rb") as f:
|
||||
return f.read()
|
||||
|
||||
+ if sys.version_info >= (3, 9):
|
||||
+
|
||||
+ def get_resource_reader(self, name: str) -> importlib.abc.TraversableResources: # type: ignore
|
||||
+ from types import SimpleNamespace
|
||||
+ from importlib.readers import FileReader
|
||||
+
|
||||
+ return FileReader(SimpleNamespace(path=self._rewritten_names[name]))
|
||||
+
|
||||
|
||||
def _write_pyc_fp(
|
||||
fp: IO[bytes], source_stat: os.stat_result, co: types.CodeType
|
||||
Index: pytest-6.2.5/testing/test_assertrewrite.py
|
||||
===================================================================
|
||||
--- pytest-6.2.5.orig/testing/test_assertrewrite.py
|
||||
+++ pytest-6.2.5/testing/test_assertrewrite.py
|
||||
@@ -771,6 +771,35 @@ class TestRewriteOnImport:
|
||||
)
|
||||
assert pytester.runpytest().ret == ExitCode.NO_TESTS_COLLECTED
|
||||
|
||||
+ @pytest.mark.skipif(
|
||||
+ sys.version_info < (3, 9),
|
||||
+ reason="importlib.resources.files was introduced in 3.9",
|
||||
+ )
|
||||
+ def test_load_resource_via_files_with_rewrite(self, pytester: Pytester) -> None:
|
||||
+ example = pytester.path.joinpath("demo") / "example"
|
||||
+ init = pytester.path.joinpath("demo") / "__init__.py"
|
||||
+ pytester.makepyfile(
|
||||
+ **{
|
||||
+ "demo/__init__.py": """
|
||||
+ from importlib.resources import files
|
||||
+
|
||||
+ def load():
|
||||
+ return files(__name__)
|
||||
+ """,
|
||||
+ "test_load": f"""
|
||||
+ pytest_plugins = ["demo"]
|
||||
+
|
||||
+ def test_load():
|
||||
+ from demo import load
|
||||
+ found = {{str(i) for i in load().iterdir() if i.name != "__pycache__"}}
|
||||
+ assert found == {{{str(example)!r}, {str(init)!r}}}
|
||||
+ """,
|
||||
+ }
|
||||
+ )
|
||||
+ example.mkdir()
|
||||
+
|
||||
+ assert pytester.runpytest("-vv").ret == ExitCode.OK
|
||||
+
|
||||
def test_readonly(self, pytester: Pytester) -> None:
|
||||
sub = pytester.mkdir("testing")
|
||||
sub.joinpath("test_readonly.py").write_bytes(
|
@ -12,11 +12,11 @@ Fix #9413
|
||||
testing/test_skipping.py | 2 --
|
||||
2 files changed, 2 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
|
||||
index 92e2dc6be7..bbc48adb49 100644
|
||||
--- a/.github/workflows/main.yml
|
||||
+++ b/.github/workflows/main.yml
|
||||
@@ -78,7 +78,7 @@ jobs:
|
||||
Index: pytest-6.2.5/.github/workflows/main.yml
|
||||
===================================================================
|
||||
--- pytest-6.2.5.orig/.github/workflows/main.yml
|
||||
+++ pytest-6.2.5/.github/workflows/main.yml
|
||||
@@ -75,7 +75,7 @@ jobs:
|
||||
os: windows-latest
|
||||
tox_env: "py39-xdist"
|
||||
- name: "windows-py310"
|
||||
@ -25,7 +25,7 @@ index 92e2dc6be7..bbc48adb49 100644
|
||||
os: windows-latest
|
||||
tox_env: "py310-xdist"
|
||||
|
||||
@@ -108,7 +108,7 @@ jobs:
|
||||
@@ -105,7 +105,7 @@ jobs:
|
||||
os: ubuntu-latest
|
||||
tox_env: "py39-xdist"
|
||||
- name: "ubuntu-py310"
|
||||
@ -34,11 +34,11 @@ index 92e2dc6be7..bbc48adb49 100644
|
||||
os: ubuntu-latest
|
||||
tox_env: "py310-xdist"
|
||||
- name: "ubuntu-pypy3"
|
||||
diff --git a/testing/test_skipping.py b/testing/test_skipping.py
|
||||
index a0b5cddabc..3010943607 100644
|
||||
--- a/testing/test_skipping.py
|
||||
+++ b/testing/test_skipping.py
|
||||
@@ -1143,8 +1143,6 @@ def test_func():
|
||||
Index: pytest-6.2.5/testing/test_skipping.py
|
||||
===================================================================
|
||||
--- pytest-6.2.5.orig/testing/test_skipping.py
|
||||
+++ pytest-6.2.5/testing/test_skipping.py
|
||||
@@ -1126,8 +1126,6 @@ def test_errors_in_xfail_skip_expression
|
||||
pypy_version_info = getattr(sys, "pypy_version_info", None)
|
||||
if pypy_version_info is not None and pypy_version_info < (6,):
|
||||
markline = markline[5:]
|
||||
|
@ -1,3 +1,11 @@
|
||||
-------------------------------------------------------------------
|
||||
Tue Dec 28 16:52:14 UTC 2021 - Ben Greiner <code@bnavigator.de>
|
||||
|
||||
- Add patch pytest-pr9173-importlib-py310.patch
|
||||
* gh#pytest-dev/pytest#9173
|
||||
* refresh pytest-pr9417-py3.10.1-fail.patch
|
||||
* fixes asdf related errors: gh#asdf-format/asdf#1027
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Dec 20 19:52:39 UTC 2021 - Matej Cepl <mcepl@suse.com>
|
||||
|
||||
|
@ -43,8 +43,10 @@ URL: https://github.com/pytest-dev/pytest
|
||||
Source: https://files.pythonhosted.org/packages/source/p/pytest/pytest-%{version}.tar.gz
|
||||
# PATCH-FIX-UPSTREAM pytest-pr8664-py3.10-test_trial_error-fail.patch -- gh#pytest-dev/pytest#8664
|
||||
Patch0: pytest-pr8664-py3.10-test_trial_error-fail.patch
|
||||
# PATCH-FIX-UPSTREAM pytest-pr9173-importlib-py310.patch -- gh#pytest-dev/pytest#9173
|
||||
Patch1: pytest-pr9173-importlib-py310.patch
|
||||
# PATCH-FIX-UPSTREAM pytest-pr9417-py3.10.1-fail.patch -- gh#pytest-dev/pytest#9417
|
||||
Patch1: pytest-pr9417-py3.10.1-fail.patch
|
||||
Patch2: pytest-pr9417-py3.10.1-fail.patch
|
||||
BuildRequires: %{python_module setuptools >= 42.0}
|
||||
BuildRequires: %{python_module setuptools_scm}
|
||||
BuildRequires: %{python_module toml}
|
||||
|
Loading…
Reference in New Issue
Block a user