diff options
Diffstat (limited to 'aoc')
| -rw-r--r-- | aoc/__init__.py | 6 | ||||
| -rw-r--r-- | aoc/__main__.py | 3 | ||||
| -rw-r--r-- | aoc/test_init.py | 2 |
3 files changed, 8 insertions, 3 deletions
diff --git a/aoc/__init__.py b/aoc/__init__.py index 07a5fe7..b13489c 100644 --- a/aoc/__init__.py +++ b/aoc/__init__.py | |||
| @@ -4,9 +4,13 @@ from typing import Generator, Any, Iterator | |||
| 4 | 4 | ||
| 5 | 5 | ||
| 6 | class BaseAssignment(ABC): | 6 | class BaseAssignment(ABC): |
| 7 | example_result = NotImplemented | ||
| 7 | def __init__(self, path): | 8 | def __init__(self, path): |
| 8 | self.path = path | 9 | self.path = path |
| 9 | 10 | ||
| 11 | def __str__(self): | ||
| 12 | return f'{self.__module__}.{self.__class__.__name__}' | ||
| 13 | |||
| 10 | def parse_item(self, item: str) -> Any: | 14 | def parse_item(self, item: str) -> Any: |
| 11 | return item | 15 | return item |
| 12 | 16 | ||
| @@ -20,4 +24,4 @@ class BaseAssignment(ABC): | |||
| 20 | yield self.parse_item(line.strip()) | 24 | yield self.parse_item(line.strip()) |
| 21 | 25 | ||
| 22 | def run(self, input: Iterator) -> Any: | 26 | def run(self, input: Iterator) -> Any: |
| 23 | raise NotImplementedError('Please implement run') | 27 | raise NotImplementedError('Please implement run') \ No newline at end of file |
diff --git a/aoc/__main__.py b/aoc/__main__.py index efb215d..6dffd61 100644 --- a/aoc/__main__.py +++ b/aoc/__main__.py | |||
| @@ -1,8 +1,7 @@ | |||
| 1 | import argparse | 1 | import argparse |
| 2 | import os | 2 | import os |
| 3 | import sys | ||
| 4 | import importlib | 3 | import importlib |
| 5 | from typing import Tuple, List | 4 | from typing import List |
| 6 | 5 | ||
| 7 | 6 | ||
| 8 | def day(assignment_part: str) -> str: | 7 | def day(assignment_part: str) -> str: |
diff --git a/aoc/test_init.py b/aoc/test_init.py new file mode 100644 index 0000000..8524086 --- /dev/null +++ b/aoc/test_init.py | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | def test_assingment_examples(assignment): | ||
| 2 | assert assignment.run(input=assignment.read_input(example=True)) == assignment.example_result | ||
