Skip to content

Commit

Permalink
day3: coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-ong committed Dec 26, 2023
1 parent af48a25 commit b7b7681
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 0 additions & 2 deletions day03/lib/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ def find_gear_parts(
self, gear: Gear, part_numbers: list[PartNumber]
) -> list[PartNumber]:
"""Returns a list of part_numbers that are touching a given gear"""
if gear.part_numbers is not None:
return gear.part_numbers
result = []
for part_number in part_numbers:
if part_number.touching(gear.col, gear.row, self.row_size):
Expand Down
10 changes: 10 additions & 0 deletions day03/tests/test_classes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from dataclasses import dataclass

import pytest

from day03.day3 import INPUT_SMALL
from day03.lib.classes import Gear, Matrix, PartNumber
from day03.lib.parsers import get_matrix
Expand Down Expand Up @@ -53,6 +55,9 @@ def test_matrix() -> None:

assert len(gears) == 3

matrix2: Matrix = Matrix(["*755."])
assert matrix2.is_engine_part(PartNumber(1, 0, 3, 755))


def test_gear() -> None:
# 69...
Expand All @@ -69,3 +74,8 @@ def test_gear() -> None:
assert gear1.gear_ratio == 0
assert gear2.gear_ratio == 69 * 78
assert gear3.gear_ratio == 0

gear_not_init = Gear(1, 1)

with pytest.raises(ValueError):
gear_not_init.gear_ratio
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ relative_files = true


[tool.coverage.report]
exclude_lines = ["if __name__ == .__main__.:", "def main"]
exclude_lines = ["if __name__ == .__main__.:", "def main", "if TYPE_CHECKING:"]
omit = ["download_inputs.py", "maker.py"]
precision = 2
skip_covered = true
Expand Down

0 comments on commit b7b7681

Please sign in to comment.