Skip to content

Commit 09e2825

Browse files
committed
skip_test parameter on initialisation
1 parent c0f856f commit 09e2825

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

aoc/models/tester.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def run_test(
3636
3737
Note:
3838
- Uses the `initialise()` function to dynamically load the solution class
39-
- Loads test input from `data/dayXX/test_YY_input.txt`
39+
- Loads test input from `tests/data/dayXX/test_YY_input.txt`
4040
- Expects solution classes to have `part1()` and `part2()` methods
4141
4242
Example:
@@ -45,7 +45,7 @@ def run_test(
4545
# Raises AssertionError if result != 42
4646
"""
4747
# Instantiate the solution object with the necessary parameters
48-
solution = initialise(day)
48+
solution = initialise(day, skip_test=False)
4949

5050
# Dynamically select the part method based on `part_num`
5151
part_method = getattr(solution, f"part{part_num}")

aoc/utils/initalise.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,31 @@
11
from importlib import import_module
22

33

4-
def initialise(day: int):
4+
def initialise(day: int, skip_test: bool = True):
55
"""
66
Dynamically load and instantiate the `Solution` class for a specific puzzle day.
77
8-
Creates a `Solution` instance for the specified day by dynamically importing
9-
the appropriate module from the solutions package.
10-
118
Args:
129
day (int): The day number (1-25) of the puzzle to initialize.
10+
skip_test (bool, optional): Whether to skip test input and use puzzle input.
11+
Defaults to True.
1312
1413
Returns:
15-
Solution: An instance of the day's `Solution` class, initialized with the day number.
14+
Solution: An instance of the day's `Solution` class, initialized with the
15+
specified parameters.
1616
1717
Note:
1818
- Expects solution modules to be named `dayXX.py` where `XX` is zero-padded day number
1919
- Expects each solution module to have a `Solution` class
2020
- Solution modules should be in the `solutions` package
21-
- Solution class must accept `day` parameter in constructor
21+
- Solution class must accept `day` and `skip_test` parameters in constructor
2222
2323
Example:
24-
>>> solution = initialise(1)
25-
# Imports `solutions.day01` and returns `Solution(day=1)`
24+
>>> solution = initialise(1) # Uses puzzle input
25+
>>> test_solution = initialise(1, skip_test=False) # Uses test input
2626
"""
27-
# Dynamically import the solution module based on the day
2827
module_name = f"solutions.day{day:02d}"
2928
solution_module = import_module(module_name)
30-
31-
# Get the `Solution` class
3229
Solution = getattr(solution_module, "Solution")
3330

34-
# Instantiate and return the `Solution` object
35-
return Solution(day=day)
31+
return Solution(day=day, skip_test=skip_test)

0 commit comments

Comments
 (0)