summaryrefslogtreecommitdiffstats
path: root/aoc
diff options
context:
space:
mode:
Diffstat (limited to 'aoc')
-rw-r--r--aoc/__init__.py6
-rw-r--r--aoc/__main__.py3
-rw-r--r--aoc/test_init.py2
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
6class BaseAssignment(ABC): 6class 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 @@
1import argparse 1import argparse
2import os 2import os
3import sys
4import importlib 3import importlib
5from typing import Tuple, List 4from typing import List
6 5
7 6
8def day(assignment_part: str) -> str: 7def 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 @@
1def test_assingment_examples(assignment):
2 assert assignment.run(input=assignment.read_input(example=True)) == assignment.example_result