I love learning math (*to some extent*) and CS theory; good literature, and the technology that provides me with all kinds of resources for those three: the web.
Hi Raphael,
Like you said, the main reason that pytest gives that error is that you need to raise ZeroDivisionError instead of catching it with try...except. Since you fixed it, I think the error might not be in the test file, but in fuel.py. For example, we need to keep getting user input only inside the main function, so, an infinite loop is reasonable to use there. And, only when x is less than or equal to y you should break out of it. That way, I think it would not stop the execution when it encounters an error. Because the convert function should only do the converting, and gauge should just return a formatted result string, the issue might be inside the main function.
Thanks so much for your help, Eda, I don't think I would have ever figured this out on my own! I was already doing the while loop inside the main function, but I was catching the exceptions in the convert() function instead of main().
I love learning math (*to some extent*) and CS theory; good literature, and the technology that provides me with all kinds of resources for those three: the web.
Hi Raphael,
Like you said, the main reason that
pytest
gives that error is that you need to raiseZeroDivisionError
instead of catching it withtry...except
. Since you fixed it, I think the error might not be in the test file, but infuel.py
. For example, we need to keep getting user input only inside themain
function, so, an infinite loop is reasonable to use there. And, only whenx
is less than or equal toy
you should break out of it. That way, I think it would not stop the execution when it encounters an error. Because theconvert
function should only do the converting, andgauge
should just return a formatted result string, the issue might be inside themain
function.Thanks so much for your help, Eda, I don't think I would have ever figured this out on my own! I was already doing the
while
loop inside the main function, but I was catching the exceptions in theconvert()
function instead ofmain()
.I'm glad it helped!