Wednesday, May 20, 2020

Wing Tips: Conditional Breakpoints Wing's Python Debugger

This Wing Tip describes how to use conditional breakpoints in Wing Pro to stop in Python code only when certain conditions are true. This is useful for isolating a single case out of many that may be processed by the same code in a particular run, in order to investigate how that case is being handled.

Conditional breakpoints are also a great way to select the runtime state for which you want to write new Python code, with the ability to immediately try out what you write.

Use Conditional Breakpoints in Debugging

To set a conditional breakpoint, right-click on the breakpoint margin in the editor and select Set Conditional Breakpoint:

Set Conditional Breakpoint

Shown above: Right-click on the breakpoint margin to set a conditional breakpoint.

Then start debug with Start/Continue in the Debug menu, from the toolbar, or as shown here with Debug Tests in the Testing tool:

Debug Unit Tests with a Conditional Breakpoint

Shown above: Select a set of unit tests and debug them to reach the conditional breakpoint, then run to the next hit, step over a few lines, and press Shift-Space to view the value of all visible variables.

Use Conditional Breakpoints to Write New Code

Since Wing lets you stop at breakpoints to work on new Python code interactively in the live runtime state of the debug process, conditional breakpoints are also a great way to select the specific runtime case for which you want to write new code. You'll have access to auto-completion that works off the actual runtime state, and can try your code right away in the Debug Console:

Interactive Development at a Conditional Breakpoint

Shown above: Enter code with auto-completion and auto-editing features that inspect the live runtime state of the debug process, then try out an invocation in the Debug Console.



That's it for now! We'll be back soon with more Wing Tips for Wing Python IDE.

As always, please don't hesitate to email support@wingware.com if you run into problems or have any questions.



from Planet Python
via read more

No comments:

Post a Comment

TestDriven.io: Working with Static and Media Files in Django

This article looks at how to work with static and media files in a Django project, locally and in production. from Planet Python via read...