apply upstream patches; fix regexps and tests for python 3.12

removes use of 2to3 (which goes away in 3.13)
This commit is contained in:
sthen
2025-02-18 20:43:33 +00:00
parent 142f92811e
commit dde66ecacc
4 changed files with 113 additions and 2 deletions
+2 -2
View File
@@ -5,7 +5,7 @@ GH_ACCOUNT= leohemsted
GH_PROJECT= smartypants.py
GH_TAGNAME= v${MODPY_DISTV}
PKGNAME= py-smartypants-${MODPY_DISTV}
REVISION= 3
REVISION= 4
CATEGORIES= textproc
@@ -14,9 +14,9 @@ PERMIT_PACKAGE= Yes
MODULES= lang/python
MODPY_PYBUILD= setuptools
TEST_DEPENDS= textproc/py-docutils
pre-test:
ln -sf ${MODPY_BIN} ${WRKDIR}/bin/python
${LOCALBASE}/bin/2to3 --write --nobackup ${WRKSRC}/tests/test_cli.py
.include <bsd.port.mk>
@@ -0,0 +1,24 @@
From ea46bf36343044a7a61ba3acce4a7f188d986ec5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20S=C3=BAkup?= <mimi.vx@gmail.com>
Date: Mon, 25 Sep 2023 10:31:37 +0200
Subject: [PATCH] Fix regexps and tests for python3.12
Index: smartypants.py
--- smartypants.py.orig
+++ smartypants.py
@@ -268,13 +268,13 @@ def smartypants(text, attr=None):
if do_quotes:
if t == "'":
# Special case: single-character ' token
- if re.match("\S", prev_token_last_char):
+ if re.match(r"\S", prev_token_last_char):
t = "&#8217;"
else:
t = "&#8216;"
elif t == '"':
# Special case: single-character " token
- if re.match("\S", prev_token_last_char):
+ if re.match(r"\S", prev_token_last_char):
t = "&#8221;"
else:
t = "&#8220;"
@@ -0,0 +1,61 @@
From ea46bf36343044a7a61ba3acce4a7f188d986ec5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20S=C3=BAkup?= <mimi.vx@gmail.com>
Date: Mon, 25 Sep 2023 10:31:37 +0200
Subject: [PATCH] Fix regexps and tests for python3.12
Index: tests/test_cli.py
--- tests/test_cli.py.orig
+++ tests/test_cli.py
@@ -34,7 +34,7 @@ class TestCLI(unittest.TestCase):
E = '&#8220;foobar&#8221;'
output = self._p([CLI_SCRIPT], T)
- self.assertEquals(output, E)
+ self.assertEqual(output, E)
def test_pipe_attr(self):
@@ -42,11 +42,11 @@ class TestCLI(unittest.TestCase):
E = T
output = self._p([CLI_SCRIPT, '--attr', '0'], T)
- self.assertEquals(output, E)
+ self.assertEqual(output, E)
E = """"foo" &#8220;bar&#8221;"""
output = self._p([CLI_SCRIPT, '--attr', 'b'], T)
- self.assertEquals(output, E)
+ self.assertEqual(output, E)
def test_skipped_elements(self):
@@ -54,19 +54,19 @@ class TestCLI(unittest.TestCase):
E = '<a>&#8220;foo&#8221;</a> <b>&#8220;bar&#8221;</b>'
output = self._p([CLI_SCRIPT], T)
- self.assertEquals(output, E)
+ self.assertEqual(output, E)
E = '<a>"foo"</a> <b>&#8220;bar&#8221;</b>'
output = self._p([CLI_SCRIPT, '--skip', 'a'], T)
- self.assertEquals(output, E)
+ self.assertEqual(output, E)
E = '<a>&#8220;foo&#8221;</a> <b>"bar"</b>'
output = self._p([CLI_SCRIPT, '--skip', 'b'], T)
- self.assertEquals(output, E)
+ self.assertEqual(output, E)
E = T
output = self._p([CLI_SCRIPT, '--skip', 'a,b'], T)
- self.assertEquals(output, E)
+ self.assertEqual(output, E)
def test_file(self):
@@ -81,4 +81,4 @@ class TestCLI(unittest.TestCase):
output = self._p([CLI_SCRIPT, F])
finally:
os.remove(F)
- self.assertEquals(output, E)
+ self.assertEqual(output, E)
@@ -0,0 +1,26 @@
From ea46bf36343044a7a61ba3acce4a7f188d986ec5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20S=C3=BAkup?= <mimi.vx@gmail.com>
Date: Mon, 25 Sep 2023 10:31:37 +0200
Subject: [PATCH] Fix regexps and tests for python3.12
Index: tests/test.py
--- tests/test.py.orig
+++ tests/test.py
@@ -24,7 +24,7 @@ class SmartyPantsTestCase(unittest.TestCase):
T = sp(TEXT)
E = '&#8220;foo&#8221; -- bar'
- self.assertEquals(T, E)
+ self.assertEqual(T, E)
attr = Attr.q | Attr.d
Attr.default = attr
@@ -32,7 +32,7 @@ class SmartyPantsTestCase(unittest.TestCase):
T = sp(TEXT)
E = '&#8220;foo&#8221; &#8212; bar'
- self.assertEquals(T, E)
+ self.assertEqual(T, E)
def test_dates(self):