First time here? Check out the FAQ!
1

jump to test file function

The code file is pipeline.py, the function is processing. it related test file is tests/test_pipeline.py, the test function is test_processing.

A hotkey will save me a lot of time to jump the files. I know there is a way to write script to make a jump to test script, any hints?

bai's avatar
103
bai
asked 2025-06-21 20:29:46 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

0

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.

Wingware Support's avatar
4.3k
Wingware Support
answered 2025-06-24 07:22:31 -0500
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