diff options
author | Efraim Flashner <efraim@flashner.co.il> | 2016-10-27 23:28:07 +0300 |
---|---|---|
committer | Efraim Flashner <efraim@flashner.co.il> | 2016-10-27 23:28:07 +0300 |
commit | aa6c09ed71acbc371731d56424ee403a69efb833 (patch) | |
tree | 1c8393dc1653a23bc614e686c1c8a68bd2cd09f1 /gnu/packages | |
parent | d18c69aa2aa59ca6a98738236c318bc1984fa4f5 (diff) | |
download | patches-aa6c09ed71acbc371731d56424ee403a69efb833.tar patches-aa6c09ed71acbc371731d56424ee403a69efb833.tar.gz |
gnu: python-parse: Fix failing test.
* gnu/packages/python.scm (python-parse)[origin]: Add patch.
* gnu/packages/patches/python-parse-too-many-fields.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
Diffstat (limited to 'gnu/packages')
-rw-r--r-- | gnu/packages/patches/python-parse-too-many-fields.patch | 52 | ||||
-rw-r--r-- | gnu/packages/python.scm | 3 |
2 files changed, 54 insertions, 1 deletions
diff --git a/gnu/packages/patches/python-parse-too-many-fields.patch b/gnu/packages/patches/python-parse-too-many-fields.patch new file mode 100644 index 0000000000..9db6b91a7f --- /dev/null +++ b/gnu/packages/patches/python-parse-too-many-fields.patch @@ -0,0 +1,52 @@ +From 32f15cfefb7c7b6476360ac65cba807aa3dfccfa Mon Sep 17 00:00:00 2001 +From: David King <dking@redhat.com> +Date: Mon, 14 Dec 2015 09:58:19 +0000 +Subject: [PATCH] Fix test_too_many_fields with Python 3.5 + +taken from https://github.com/r1chardj0n3s/parse/pull/34 + +Python versions before 3.5 had a limit of 100 groups in regular +expressions. This limit was removed during 3.5 development: + +http://bugs.python.org/issue22437 +https://hg.python.org/cpython/rev/0b85ea4bd1af + +The test_too_many_fields test asserts that the limit exists by +attempting to parse a string with 15 fields, which triggers the 100 +named groups limit. + +Adjust the test so that if first checks to see whether the limit of 100 +named groups exists, and only assert that parsing 15 fields fails if +that is the case. +--- + test_parse.py | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +diff --git a/test_parse.py b/test_parse.py +index c524349..1d50568 100755 +--- a/test_parse.py ++++ b/test_parse.py +@@ -6,6 +6,7 @@ + + import unittest + from datetime import datetime, time ++import re + + import parse + +@@ -624,8 +625,13 @@ def test_mixed_type_variant(self): + self.assertEqual(r.fixed[21], 'spam') + + def test_too_many_fields(self): +- p = parse.compile('{:ti}' * 15) +- self.assertRaises(parse.TooManyFields, p.parse, '') ++ # Python 3.5 removed the limit of 100 named groups in a regular expression, ++ # so only test for the exception if the limit exists. ++ try: ++ re.compile("".join("(?P<n{n}>{n}-)".format(n=i) for i in range(101))) ++ except AssertionError: ++ p = parse.compile('{:ti}' * 15) ++ self.assertRaises(parse.TooManyFields, p.parse, '') + + + class TestSearch(unittest.TestCase): diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm index 691c5deab0..a5fabd0e01 100644 --- a/gnu/packages/python.scm +++ b/gnu/packages/python.scm @@ -1407,7 +1407,8 @@ backported for previous versions of Python from 2.4 to 3.3.") (uri (pypi-uri "parse" version)) (sha256 (base32 - "0y31i3mwgv35qn0kzzjn9q8jqfdqmbi6sr6yfvn8rq4lqjm5lhvi")))) + "0y31i3mwgv35qn0kzzjn9q8jqfdqmbi6sr6yfvn8rq4lqjm5lhvi")) + (patches (search-patches "python-parse-too-many-fields.patch")))) (build-system python-build-system) (arguments `(#:phases |