From cabbb573847a97b09cd41274eae6b1bf148ad351 Mon Sep 17 00:00:00 2001 From: Jens Peters Date: Sun, 15 Dec 2024 19:39:39 +0100 Subject: [PATCH] 2015: Use pytest --- .github/workflows/main.yml | 6 +++++- 2015/README.md | 2 +- 2015/day00.py | 14 -------------- 2015/day01.py | 18 ------------------ 2015/requirements.txt | 1 + 2015/test_day00.py | 7 +++++++ 2015/test_day01.py | 11 +++++++++++ 7 files changed, 25 insertions(+), 34 deletions(-) delete mode 100644 2015/day00.py delete mode 100644 2015/day01.py create mode 100644 2015/requirements.txt create mode 100644 2015/test_day00.py create mode 100644 2015/test_day01.py diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 45c5ef8..4f4d590 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,10 +18,14 @@ jobs: uses: actions/setup-python@v5 with: python-version: '3.13' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt - name: Run AoC 2015 run: | cd 2015 - python -m unittest *.py + pytest AoC-2017: runs-on: ubuntu-latest diff --git a/2015/README.md b/2015/README.md index 67d48d7..8e3ecad 100644 --- a/2015/README.md +++ b/2015/README.md @@ -11,5 +11,5 @@ Only Linux has been tested. Other platforms might just work though. ## Compile & run ```bash -python -m unittest *.py +pytest ``` diff --git a/2015/day00.py b/2015/day00.py deleted file mode 100644 index e23c0fd..0000000 --- a/2015/day00.py +++ /dev/null @@ -1,14 +0,0 @@ -import unittest - -from util import read_input - - -class Day01(unittest.TestCase): - - def test_part01(self): - input_data = read_input("day00-input.txt") - - self.assertEqual(input_data, '0') - -if __name__ == '__main__': - unittest.main() diff --git a/2015/day01.py b/2015/day01.py deleted file mode 100644 index aee0e33..0000000 --- a/2015/day01.py +++ /dev/null @@ -1,18 +0,0 @@ -import unittest - -from util import read_input - - -class Day00(unittest.TestCase): - - def test_part01(self): - input_data = read_input("day01-input.txt") - - up = input_data.count(')') - down = input_data.count('(') - floor = abs(up - down) - - self.assertEqual(floor, 138) - -if __name__ == '__main__': - unittest.main() diff --git a/2015/requirements.txt b/2015/requirements.txt new file mode 100644 index 0000000..d197ada --- /dev/null +++ b/2015/requirements.txt @@ -0,0 +1 @@ +pytest==8.3.4 diff --git a/2015/test_day00.py b/2015/test_day00.py new file mode 100644 index 0000000..f3d3319 --- /dev/null +++ b/2015/test_day00.py @@ -0,0 +1,7 @@ +from util import read_input + + +def test_part01(): + input_data = read_input("day00-input.txt") + + assert input_data == '0' diff --git a/2015/test_day01.py b/2015/test_day01.py new file mode 100644 index 0000000..a56a3af --- /dev/null +++ b/2015/test_day01.py @@ -0,0 +1,11 @@ +from util import read_input + + +def test_part01(): + input_data = read_input("day01-input.txt") + + up = input_data.count(')') + down = input_data.count('(') + floor = abs(up - down) + + assert floor == 138