Advertisement
nikolask

CS50P - PSET5_test_fuel.py

Aug 20th, 2023
857
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | Source Code | 0 0
  1. # https://cs50.harvard.edu/python/2022/psets/5/test_fuel/
  2.  
  3. import pytest
  4. from fuel import convert, gauge
  5.  
  6. def test_zero_division():
  7.     with pytest.raises(ZeroDivisionError):
  8.         convert("1/0")
  9.  
  10. def test_y_less_than_x():
  11.     with pytest.raises(ValueError):
  12.         convert("3/2")
  13.  
  14. def test_convert():
  15.     assert convert("0/1") == 0
  16.     assert convert("1/2") == 50
  17.     assert convert("4/4") == 100
  18.  
  19. def test_gauge():
  20.     assert gauge(0) == "E"
  21.     assert gauge(1) == "E"
  22.     assert gauge(5) == "5%"
  23.     assert gauge(80) == "80%"
  24.     assert gauge(99) == "F"
  25.     assert gauge(100) == "F"
Tags: CS50P
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement