Queer European MD passionate about IT

test_fuel.py 800 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. from fuel import convert, gauge
  2. def main():
  3. test_convert()
  4. test_gauge()
  5. test_value_error()
  6. test_zero_division_error()
  7. def test_convert():
  8. assert convert("0/4") == 0
  9. assert convert("1/4") == 25
  10. assert convert("4/4") == 100
  11. def test_value_error():
  12. try:
  13. convert("5/4")
  14. except ValueError:
  15. pass
  16. else:
  17. raise Exception("ValueError not raised with y>x")
  18. def test_zero_division_error():
  19. try:
  20. convert("5/0")
  21. except ZeroDivisionError:
  22. pass
  23. else:
  24. raise Exception("ZeroDivisionError not raised with y = 0")
  25. def test_gauge():
  26. assert gauge(100) == 'F'
  27. assert gauge(99) == 'F'
  28. assert gauge(0) == 'E'
  29. assert gauge(1) == 'E'
  30. assert gauge(27) == '27%'
  31. if __name__ == '__main__':
  32. main()