tests/extmod/re_sub.py: Fix test execution on Python 3.13.
This commit fixes a test failure for `extmod/re_sub.py` where the code, whilst being correct, would not make the test pass due to a newer Python version than expected. On Python 3.13, running `tests/extmod/re_sub.py` would yield a deprecation warning about `re.sub` not providing the match count as a keyword parameter. This warning would be embedded in the expected test result and thus the test would always fail. Co-authored-by: stijn <stijn@ignitron.net> Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit is contained in:
committed by
Damien George
parent
1b4c969ce0
commit
e73cf71a24
@@ -10,6 +10,8 @@ except AttributeError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
def multiply(m):
|
||||
return str(int(m.group(0)) * 2)
|
||||
@@ -47,7 +49,11 @@ print(re.sub("(abc)", r"\g<1>\g<1>", "abc"))
|
||||
print(re.sub("a", "b", "c"))
|
||||
|
||||
# with maximum substitution count specified
|
||||
print(re.sub("a", "b", "1a2a3a", 2))
|
||||
if sys.implementation.name != "micropython":
|
||||
# On CPython 3.13 and later the substitution count must be a keyword argument.
|
||||
print(re.sub("a", "b", "1a2a3a", count=2))
|
||||
else:
|
||||
print(re.sub("a", "b", "1a2a3a", 2))
|
||||
|
||||
# invalid group
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user