Skip to content

Commit

Permalink
fix test cov misses
Browse files Browse the repository at this point in the history
  • Loading branch information
wimglenn committed Nov 20, 2024
1 parent 44db6c0 commit ab47761
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion aocd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from . import utils
from .exceptions import AocdError
from .get import get_data
from .get import get_puzzle
from .get import get_day_and_year
from .post import submit as _impartial_submit

Expand Down Expand Up @@ -48,7 +49,7 @@ def __getattr__(name: str) -> t.Any:
return get_data(day=day, year=year)
if name == "puzzle":
day, year = get_day_and_year()
return get.get_puzzle(day=day, year=year)
return get_puzzle(day=day, year=year)
if name == "submit":
try:
day, year = get_day_and_year()
Expand Down
11 changes: 11 additions & 0 deletions tests/test_aocd.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,14 @@ def test_data_in_interactive_mode(monkeypatch, mocker, freezer):
def test_attribute_errors_have_context():
with pytest.raises(AttributeError("module 'aocd' has no attribute 'nope'")):
aocd.nope


def test_import_puzzle(mocker):
fake_stack = [("~/2023/q21.py", 1, "<test>", "from aocd import data")]
mocker.patch("aocd.get.traceback.extract_stack", return_value=fake_stack)
mocker.patch("aocd.models.Puzzle.input_data", "test puzzle")
from aocd import puzzle

assert puzzle.year == 2023
assert puzzle.day == 21
assert puzzle.input_data == "test puzzle"

0 comments on commit ab47761

Please sign in to comment.