Ask Your Question
1

Running tests with pyserial and python input function

asked 2020-04-02 03:52:45 -0600

piscvau gravatar image

updated 2020-04-02 09:28:05 -0600

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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-04-02 09:27:25 -0600

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2020-04-02 03:52:45 -0600

Seen: 698 times

Last updated: Apr 02