always return a number

This commit is contained in:
Matthias 2021-12-29 15:53:04 +01:00
parent 624b16a419
commit 972f93f6d8
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076
2 changed files with 6 additions and 6 deletions

View File

@ -504,7 +504,7 @@ def extract_serial_numbers(serials, expected_quantity, next_number: int):
if group in numbers: if group in numbers:
errors.append(_("Duplicate serial: {g}".format(g=group))) errors.append(_("Duplicate serial: {g}".format(g=group)))
else: else:
numbers.append(group) numbers.append(int(group))
if len(errors) > 0: if len(errors) > 0:
raise ValidationError(errors) raise ValidationError(errors)

View File

@ -255,15 +255,15 @@ class TestSerialNumberExtraction(TestCase):
sn = e("4, 1+2", 4, 1) sn = e("4, 1+2", 4, 1)
self.assertEqual(len(sn), 4) self.assertEqual(len(sn), 4)
self.assertEqual(sn, ["4", 1, 2, 3]) self.assertEqual(sn, [4, 1, 2, 3])
sn = e("~", 1, 1) sn = e("~", 1, 1)
self.assertEqual(len(sn), 1) self.assertEqual(len(sn), 1)
self.assertEqual(sn, ['1']) self.assertEqual(sn, [1])
sn = e("~", 1, 3) sn = e("~", 1, 3)
self.assertEqual(len(sn), 1) self.assertEqual(len(sn), 1)
self.assertEqual(sn, ['3']) self.assertEqual(sn, [3])
sn = e("~+", 2, 5) sn = e("~+", 2, 5)
self.assertEqual(len(sn), 2) self.assertEqual(len(sn), 2)
@ -305,11 +305,11 @@ class TestSerialNumberExtraction(TestCase):
sn = e("1 3-5 9+2", 7, 1) sn = e("1 3-5 9+2", 7, 1)
self.assertEqual(len(sn), 7) self.assertEqual(len(sn), 7)
self.assertEqual(sn, ['1', 3, 4, 5, 9, 10, 11]) self.assertEqual(sn, [1, 3, 4, 5, 9, 10, 11])
sn = e("1,3-5,9+2", 7, 1) sn = e("1,3-5,9+2", 7, 1)
self.assertEqual(len(sn), 7) self.assertEqual(len(sn), 7)
self.assertEqual(sn, ['1', 3, 4, 5, 9, 10, 11]) self.assertEqual(sn, [1, 3, 4, 5, 9, 10, 11])
sn = e("~+2", 3, 14) sn = e("~+2", 3, 14)
self.assertEqual(len(sn), 3) self.assertEqual(len(sn), 3)