From b062e0f2abc189f352e019bac6854f469e9dfc8c Mon Sep 17 00:00:00 2001 From: Tom van der Lee Date: Fri, 3 Dec 2021 14:15:14 +0100 Subject: Added tests --- aoc/__init__.py | 6 +++++- aoc/__main__.py | 3 +-- aoc/test_init.py | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 aoc/test_init.py (limited to 'aoc') 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 class BaseAssignment(ABC): + example_result = NotImplemented def __init__(self, path): self.path = path + def __str__(self): + return f'{self.__module__}.{self.__class__.__name__}' + def parse_item(self, item: str) -> Any: return item @@ -20,4 +24,4 @@ class BaseAssignment(ABC): yield self.parse_item(line.strip()) def run(self, input: Iterator) -> Any: - raise NotImplementedError('Please implement run') + 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 @@ import argparse import os -import sys import importlib -from typing import Tuple, List +from typing import List 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 @@ +def test_assingment_examples(assignment): + assert assignment.run(input=assignment.read_input(example=True)) == assignment.example_result -- cgit v1.2.3