Skip to content

Commit

Permalink
split "part" out of basename, for users who want separate filenames f…
Browse files Browse the repository at this point in the history
…or part 1 and part 2. closes #152
  • Loading branch information
wimglenn committed Dec 21, 2024
1 parent 89b8698 commit b6f8ca7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions aocd/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ def giveup(msg):
filename = frame[0]
linetxt = frame[-1] or ""
basename = os.path.basename(filename)
basename = basename.split("part")[0]
reasons_to_skip_frame = [
not re.search(pattern_day, basename), # no digits in filename
filename == __file__, # here
Expand Down
8 changes: 8 additions & 0 deletions tests/test_date_introspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,11 @@ def test_no_numbers_in_py_filename_but_date_in_abspath(mocker):
day, year = get_day_and_year()
assert day == 2
assert year == 2022


def test_get_day_and_year_separate_part2_filename(mocker):
stack = [("AoC2024/day14part2.py", 1, "<test>", "from aocd import data")]
mocker.patch("aocd.get.traceback.extract_stack", return_value=stack)
day, year = get_day_and_year()
assert day == 14
assert year == 2024

0 comments on commit b6f8ca7

Please sign in to comment.