advent_of_code_2020/day1/test_day1.py

34 lines
996 B
Python
Raw Normal View History

2022-08-18 21:42:55 -05:00
#! /usr/bin/env python3
import pathlib
import pytest
2022-08-19 12:00:14 -05:00
import day1 as aoc
2022-08-18 21:42:55 -05:00
PUZZLE_DIR = pathlib.Path(__file__).parent
#these test fixtures setup the test, mainly by reading the filename into a string in this simple case.
@pytest.fixture
def example1():
puzzle_input = (PUZZLE_DIR / "example1").read_text().strip()
return aoc.parse(puzzle_input)
@pytest.fixture
def example2():
puzzle_input = (PUZZLE_DIR / "example2").read_text().strip()
return aoc.parse(puzzle_input)
2022-08-19 12:00:14 -05:00
# @pytest.mark.skip(reason="Not implemented")
2022-08-18 21:42:55 -05:00
def test_parse_example1(example1):
"""Test that input is parsed properly"""
2022-08-19 12:00:14 -05:00
assert example1 == [1721, 979, 366, 299, 675, 1456]
2022-08-18 21:42:55 -05:00
2022-08-19 12:00:14 -05:00
# @pytest.mark.skip(reason="Not implemented")
2022-08-18 21:42:55 -05:00
def test_part1_example1(example1):
"""Test part 1 on example input"""
2022-08-19 12:00:14 -05:00
assert aoc.part1(example1) == 514579
2022-08-18 21:42:55 -05:00
2022-08-19 12:00:14 -05:00
# @pytest.mark.skip(reason="Not implemented")
def test_part2_example2(example1):
2022-08-18 21:42:55 -05:00
"""Test part 2 on example input"""
2022-08-19 12:00:14 -05:00
assert aoc.part2(example1) == 241861950