handling input/output in tests
Function tests of user's code returns "There was an error when running your code." If there is an input()
call. Strictly speaking, this is correct, because there is no input provided in the tests. However, it is confusing.
Some options (all some or none):
- make
input()
do nothing (like how it doesn't print the prompt in io-tests) - make the interactive execution work with the standard
if __name__=="__main__":
pattern. - provide a traceback (or at least return the error) from executing the user's code when setting up assert tests.
I don't like (1) as much, because it is considered bad practice (input/output outside of functions can interfere with testing suites and documentation tools). Option (2) is quite nice as standard Python, and better mimics execution of Python scripts. Option (3) is also nice, but requires some extra thought and design, so that they don't get multiple tracebacks from hitting "run".