1234567891011121314151617181920212223242526272829303132333435363738394041 |
- from fuel import convert, gauge
- def main():
- test_convert()
- test_gauge()
- test_value_error()
- test_zero_division_error()
- def test_convert():
- assert convert("0/4") == 0
- assert convert("1/4") == 25
- assert convert("4/4") == 100
- def test_value_error():
- try:
- convert("5/4")
- except ValueError:
- pass
- else:
- raise Exception("ValueError not raised with y>x")
- def test_zero_division_error():
- try:
- convert("5/0")
- except ZeroDivisionError:
- pass
- else:
- raise Exception("ZeroDivisionError not raised with y = 0")
- def test_gauge():
- assert gauge(100) == 'F'
- assert gauge(99) == 'F'
- assert gauge(0) == 'E'
- assert gauge(1) == 'E'
- assert gauge(27) == '27%'
- if __name__ == '__main__':
- main()
|