Skip to content

Commit fc28ac0

Browse files
committed
Reproduce #26 in test suite (IndexError: no such group)
1 parent 4634688 commit fc28ac0

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

rotate_backups/tests.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Test suite for the `rotate-backups' Python package.
22
#
33
# Author: Peter Odding <peter@peterodding.com>
4-
# Last Change: February 14, 2020
4+
# Last Change: May 17, 2020
55
# URL: https://github.com/xolox/python-rotate-backups
66

77
"""Test suite for the `rotate-backups` package."""
@@ -486,6 +486,21 @@ def test_invalid_timestamp_pattern(self):
486486
timestamp_pattern=r'(?P<year>\d{4})-(?P<month>\d{2})',
487487
)
488488

489+
def test_optional_captures(self):
490+
"""Test that the hour/minute/second captures are truly optional."""
491+
with TemporaryDirectory(prefix='rotate-backups-', suffix='-test-suite') as root:
492+
touch(os.path.join(root, 'prometheus-grafana-production-09-04-2020.tar.gz'))
493+
program = RotateBackups(
494+
rotation_scheme=dict(monthly='always'),
495+
timestamp_pattern=r'(?P<day>\d{2})-(?P<month>\d{2})-(?P<year>\d{4})',
496+
)
497+
location = coerce_location(root)
498+
backups = program.collect_backups(location)
499+
assert len(backups) == 1
500+
assert backups[0].timestamp.day == 9
501+
assert backups[0].timestamp.month == 4
502+
assert backups[0].timestamp.year == 2020
503+
489504
def create_sample_backup_set(self, root):
490505
"""Create a sample backup set to be rotated."""
491506
for name in SAMPLE_BACKUP_SET:

0 commit comments

Comments
 (0)