How to make pytest wait for (manual) user action?

前端 未结 5 1801
抹茶落季
抹茶落季 2021-02-13 15:36

We are sucessfully using pytest (Python 3) to run a test suite testing some hardware devices (electronics). For a subset of these tests, we need the tester to change the hardwa

5条回答
  •  情话喂你
    2021-02-13 16:29

    Solutions that use the global pytest.config object no longer work. For my use case, using --capture=sys together with a custom input() that uses stdin and stdout directly works well.

    
    def fd_input(prompt):
        with os.fdopen(os.dup(1), "w") as stdout:
            stdout.write("\n{}? ".format(prompt))
    
        with os.fdopen(os.dup(2), "r") as stdin:
            return stdin.readline()
    

提交回复
热议问题