First time here? Check out the FAQ!
1

Running tests with pyserial and python input function

Hello I am running 2 tests using PySerial. I am using print() and input() in the test to request the user to connect and disconnect devices on the USB ports of the machine. If I run the 2 tests in sequence ( they are numbered to impose the order) using debug, most of the time but not always, the second test fails to open the port.(report port is busy in serial Posix) If I run only the second test alone, using debug, it passes all the time.

I suspect possible interaction with the debugger keeping the port busy after the first test.

My question : How can I run the tests, using the testing tool but without the debugger and yet be able to answer to the input requests? in other words, where is the stdout when it not in the debugger window?

piscvau's avatar
486
piscvau
asked 2020-04-02 03:52:45 -0600
Wingware Support's avatar
4k
Wingware Support
updated 2020-04-02 09:28:05 -0600
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

0

The Testing tool isn't designed to allow access to stdin on the testing process, since it's more for unattended and not interactive tests. One idea is to run your tests in the OS Commands tool (for example by using the Execute items in the Debug menu). Or change the test to throw up a dialog instead.

I'm not sure how specifically the debugger would cause an interaction, since it just runs the same code in the same order. However, it does set up a stdin wrapper so I/O can occur in the Debug I/O tool in Wing, and maybe that is causing a problem. There is a pref to turn that off: Debugger > Advanced > Use sys.std Wrapper. But I think you would also need to check the Debugger > I/O > Use External Console preference so you can interact with the process. That opens a separate console rather than redirecting I/O to the Debug I/O tool.

Please let us know if none of this works.

Wingware Support's avatar
4k
Wingware Support
answered 2020-04-02 09:27:25 -0600
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss.

Add Answer