PyCharm Plugin: Adding action to EditorPopupMenu.Run to run individual pytest with custom configuration
Answered
I'm new to plugin development I'm trying to create a Pycharm plugin to add an option to the EditorPopupMenu which will only show up if a pytest function is right clicked. I'm aiming for the action to run the individual pytest function which was clicked and be able to do it with a custom configuration to run the tests with a custom built framework tool.
I know adding an option to the EditorPopupMenu can be done with this:
<action id="HelloWorld" class="actions.HelloWorldAction" text="Hello World">
<add-to-group group-id="EditorPopupMenu.Run" anchor="first"></add-to-group>
</action>
But I'm having trouble finding documentation that helps with the rest of what I need to do which is:
1. Determine if what was right clicked was a function which follows the naming convention of pytest (test_func)
2. Run that test function with a custom configuration
Please sign in to leave a comment.
Hi,
To get the element clicked in the editor, you can use anActionEvent.getData(CommonDataKeys.PSI_ELEMENT)
Thanks for the response. I was actually able to achieve the functionality I was looking for a couple days after my initial question. Just for future reference in case anyone else stumbles upon this thread looking for help, these links were very helpful to me:
Intellij SDK Code examples: https://github.com/JetBrains/intellij-sdk-code-samples
Pycharm specific Intellij SDK docs: https://plugins.jetbrains.com/docs/intellij/pycharm.html
Intellij Source Code https://github.com/JetBrains/intellij-community
As well as looking up open source plugin source codes with related functionality.