Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion faststack/io/variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
)

# Trailing `-backup(\d+)?` token at end of (stripped) stem.
_BACKUP_TRAILING_RE = re.compile(r"(?:^|-)([Bb][Aa][Cc][Kk][Uu][Pp])(\d+)?$")
_BACKUP_TRAILING_RE = re.compile(r"-([Bb][Aa][Cc][Kk][Uu][Pp])(\d+)?$")


@dataclass
Expand Down
11 changes: 11 additions & 0 deletions faststack/tests/test_variants_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ def test_backup_sorting(self):
self.assertEqual(group.backup_paths[2].name, "img-backup2.jpg")
self.assertEqual(group.backup_paths[10].name, "img-backup10.jpg")

def test_plain_backup_filename_is_not_variant(self):
"""A literal backup.jpg filename should not create an empty group key."""
groups = build_variant_map([Path("backup.jpg")])

self.assertIn("backup", groups)
self.assertNotIn("", groups)

group = groups["backup"]
self.assertEqual(group.main_path.name, "backup.jpg")
self.assertEqual(group.backup_paths, {})

def test_developed_backup_handling(self):
"""Verify developed backups are handled correctly."""
# Policy: developed-backup is "developed" candidate, AND "backup" candidate.
Expand Down