PyCharm Plugin: Adding action to EditorPopupMenu.Run to run individual pytest with custom configuration


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>

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



  1. You should override the AnAction.update() method and enable and show it when the function following the naming convention.  See:
    To get the element clicked in the editor, you can use anActionEvent.getData(CommonDataKeys.PSI_ELEMENT)
  2. See

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:
Pycharm specific Intellij SDK docs: 
Intellij Source Code

As well as looking up open source plugin source codes with related functionality.



Please sign in to leave a comment.