Skip to content

Commit

Permalink
Merge pull request #154 from wimglenn/issue-152
Browse files Browse the repository at this point in the history
Date introspection: split "part" out of filename
  • Loading branch information
wimglenn authored Dec 21, 2024
2 parents 89b8698 + b6f8ca7 commit 26d27ec
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 26d27ec

Please sign in to comment.