15
0

Accepting request 1318368 from devel:languages:python

- Rewrite py39.patch to support all Python 3 versions we ship.

OBS-URL: https://build.opensuse.org/request/show/1318368
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-prestring?expand=0&rev=4
This commit is contained in:
2025-11-18 14:39:59 +00:00
committed by Git OBS Bridge
3 changed files with 28 additions and 35 deletions

View File

@@ -1,26 +1,15 @@
From 55165f7b1a622577801f8d6c2bd3d0f16555be4b Mon Sep 17 00:00:00 2001
From: podhmo <ababjam61+github@gmail.com>
Date: Sun, 28 Mar 2021 14:27:35 +0900
Subject: [PATCH] Fix test for py39 (#75)
* test: remove try-except
* test: fix tests (work-around)
---
prestring/tests/test_lazy_object.py | 33 +++++++++++++++++------------
1 file changed, 20 insertions(+), 13 deletions(-)
diff --git a/prestring/tests/test_lazy_object.py b/prestring/tests/test_lazy_object.py
index f528009..a41457f 100644
--- a/prestring/tests/test_lazy_object.py
+++ b/prestring/tests/test_lazy_object.py
@@ -29,23 +29,30 @@ def test_with_actual_types(self):
Index: prestring-0.9.0/prestring/tests/test_lazy_object.py
===================================================================
--- prestring-0.9.0.orig/prestring/tests/test_lazy_object.py
+++ prestring-0.9.0/prestring/tests/test_lazy_object.py
@@ -29,23 +29,27 @@ class LazyArgumentsTests(unittest.TestCa
self.assertEqual(str(target), "x: int, y: bool, *")
def test_with_actual_types2(self):
- try:
- import typing as t
-
+ import typing as t
- target = self._makeOne(
- ["x", "y", "z"],
- types={
@@ -29,8 +18,12 @@ index f528009..a41457f 100644
- "z": t.Sequence[t.Optional[int]],
- },
- )
+ import typing as t
+
- self.assertEqual(
- str(target),
- "x: int, y: 'typing.Union[int, NoneType]', z: 'typing.Sequence[typing.Union[int, NoneType]]'",
- )
- except ImportError:
- pass
+ target = self._makeOne(
+ ["x", "y", "z"],
+ types={
@@ -43,18 +36,13 @@ index f528009..a41457f 100644
+ # TODO: fix, this is work-around
+ import sys
+
+ if (3, 9) > sys.version_info:
self.assertEqual(
str(target),
"x: int, y: 'typing.Union[int, NoneType]', z: 'typing.Sequence[typing.Union[int, NoneType]]'",
)
- except ImportError:
- pass
+ if sys.version_info[:2] >= (3, 14):
+ match = "x: int, y: 'int | None', z: 'typing.Sequence[int | None]'"
+ elif sys.version_info[:2] > (3, 9):
+ match = "x: int, y: 'typing.Optional[int]', z: 'typing.Sequence[typing.Optional[int]]'"
+ else:
+ self.assertEqual(
+ str(target),
+ "x: int, y: 'typing.Optional[int]', z: 'typing.Sequence[typing.Optional[int]]'",
+ )
+ match = "x: int, y: 'typing.Union[int, NoneType]', z: 'typing.Sequence[typing.Union[int, NoneType]]'"
+ self.assertEqual(str(target), match)
@test_target("prestring:LazyKeywords")

View File

@@ -1,3 +1,8 @@
-------------------------------------------------------------------
Tue Nov 18 03:55:44 UTC 2025 - Steve Kowalik <steven.kowalik@suse.com>
- Rewrite py39.patch to support all Python 3 versions we ship.
-------------------------------------------------------------------
Tue Jun 3 12:07:31 UTC 2025 - Markéta Machová <mmachova@suse.com>

View File

@@ -1,7 +1,7 @@
#
# spec file for package python-prestring
#
# Copyright (c) 2025 SUSE LLC
# Copyright (c) 2025 SUSE LLC and contributors
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -35,14 +35,14 @@ BuildArch: noarch
BuildRequires: %{python_module evilunit}
BuildRequires: %{python_module typing_extensions}
# /SECTION
Requires: python-typing_extensions
%python_subpackages
%description
Python source code generation library (with overuse with-syntax).
%prep
%setup -q -n prestring-%{version}
%autopatch -p1
%autosetup -p1 -n prestring-%{version}
%build
%pyproject_wheel
@@ -58,6 +58,6 @@ Python source code generation library (with overuse with-syntax).
%doc README.rst
%license LICENSE
%{python_sitelib}/prestring
%{python_sitelib}/prestring-%{version}*-info
%{python_sitelib}/prestring-%{version}.dist-info
%changelog