First time here? Check out the FAQ!

Revision history  [back]

I'm not finding an existing example of this but you would call GetCurrentSourceScopes on the CAPIApplication object in the Wing API to get the scope name at the current focus. Then write your own code to work up the file name to open and target scope name for the unit test.

Then you can use GetAnalysis on CAPIApplication to get the CAPIStaticAnalysis code analysis for the target (the unit test file), call GetSymbolInfo on that to get the CAPISymbolInfo for the unit test def (which includes the line number and position of the symbol), and finally call OpenEditor on CAPIApplication to open the unit test file and then ScrollToLine on its CAPIEditor object to show and select the unit test def.

Once this is working you would bind a key to your newly created command. So if the def of your script is show_unit_test you would find a key to the command show-unit-test. You can also have args for your command so could bind to something like 'show-unit-test(test_system='pytest') or whatever if you need different algorithms to find the test file for difference cases.

See https://wingware.com/doc/scripting for details on scripting Wing, including a simple example tutorial.