Files
python-learning/exercises/01-core/01-basics/test_basics.py
T

31 lines
936 B
Python

import pytest
from basics import celsius_to_fahrenheit, classify_score, fizzbuzz_label, sum_up_to
def test_celsius_to_fahrenheit() -> None:
assert celsius_to_fahrenheit(0.0) == pytest.approx(32.0)
assert celsius_to_fahrenheit(100.0) == pytest.approx(212.0)
assert celsius_to_fahrenheit(-40.0) == pytest.approx(-40.0)
def test_classify_score() -> None:
assert classify_score(0) == "fail"
assert classify_score(50) == "pass"
assert classify_score(80) == "good"
assert classify_score(95) == "excellent"
assert classify_score(101) == "invalid"
assert classify_score(-1) == "invalid"
def test_sum_up_to() -> None:
assert sum_up_to(0) == 0
assert sum_up_to(-5) == 0
assert sum_up_to(10) == 55
def test_fizzbuzz_label() -> None:
assert fizzbuzz_label(1) == "1"
assert fizzbuzz_label(3) == "Fizz"
assert fizzbuzz_label(5) == "Buzz"
assert fizzbuzz_label(15) == "FizzBuzz"