Fixes: #13722 - Correct range expansion code when a numeric set is used

This commit is contained in:
Daniel Sheppard 2024-02-28 11:41:36 -06:00
parent edb7d24b45
commit 017a66b5f9
2 changed files with 11 additions and 2 deletions

View File

@ -60,7 +60,7 @@ def parse_alphanumeric_range(string):
return []
except ValueError:
begin, end = dash_range, dash_range
if begin.isdigit() and end.isdigit():
if begin.isdigit() and end.isdigit() and not begin == end:
if int(begin) >= int(end):
raise forms.ValidationError(_('Range "{value}" is invalid.').format(value=dash_range))

View File

@ -191,7 +191,16 @@ class ExpandAlphanumeric(TestCase):
self.assertEqual(sorted(expand_alphanumeric_pattern(input)), output)
def test_set(self):
def test_set_numeric(self):
input = 'r[1,2]a'
output = sorted([
'r1a',
'r2a',
])
self.assertEqual(sorted(expand_alphanumeric_pattern(input)), output)
def test_set_alpha(self):
input = '[r,t]1a'
output = sorted([
'r1a',