How to test a function with input call?

后端 未结 6 1075
野性不改
野性不改 2020-11-29 04:16

I have a console program written in Python. It asks the user questions using the command:

some_input = input(\'Answer the question:\', ...)

6条回答
  •  被撕碎了的回忆
    2020-11-29 05:09

    Since I need the input() call to pause and check my hardware status LEDs, I had to deal with the situation without mocking. I used the -s flag.

    python -m pytest -s test_LEDs.py
    

    The -s flag essentially means: shortcut for --capture=no.

提交回复
热议问题