diff options
| author | 2021-12-03 14:15:14 +0100 | |
|---|---|---|
| committer | 2021-12-03 14:15:51 +0100 | |
| commit | b062e0f2abc189f352e019bac6854f469e9dfc8c (patch) | |
| tree | 95a7a72cf56061278297f6326c8e3f9519432d53 /aoc | |
| parent | f3c3fa9b94bc61b90a029bb74c98215b45c5be15 (diff) | |
| download | 2021-b062e0f2abc189f352e019bac6854f469e9dfc8c.tar.gz 2021-b062e0f2abc189f352e019bac6854f469e9dfc8c.tar.bz2 2021-b062e0f2abc189f352e019bac6854f469e9dfc8c.zip | |
Added tests
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 | ||
