Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unittest Shortcut not working #172

Closed
maurerle opened this issue Mar 12, 2022 · 5 comments · Fixed by #203
Closed

Unittest Shortcut not working #172

maurerle opened this issue Mar 12, 2022 · 5 comments · Fixed by #203
Assignees
Labels
Milestone

Comments

@maurerle
Copy link

Description of your problem

After setting the "Run Unittest" shortcut in spyder preferences -> keyboard shortcuts to Alt+Shift+F11, it is not callable through the shortcut

What steps will reproduce the problem?

  1. Spyder Preferences -> Keyboard Shortcut -> search test
  2. Enter Shortcut
  3. Apply & test shortcut

What is the expected output? What do you see instead?

Nothing happens. I'd expect it to trigger the action like clicking the UI button in Run -> Run unit tests

Paste traceback/error below (if applicable)

(Copy from error dialog or View > Panes > Internal Console)

<!--- PASTE TRACEBACK HERE --->

Key versions and other information:

  • Spyder version: 5.2.2
  • Version of spyder-unittest plugin: 0.5.0
  • Installation method for Spyder and the unittest plugin:pip
  • Python version: 3.9.7
  • Testing framework used: pytest
  • Testing framework version: 6.2.5
  • Operating system: GNU/Linux Debian 11 Bullseye
@jitseniesen
Copy link
Member

In Spyder v4, if I remember correctly, the shortcut was set to Alt+Shift+F11 by default. The PR above leaves the shortcut not set to any key sequence, because I don't know how to do this from a plugin. I am also not sure whether we want plugins to assign shortcuts because this will lead to collisions at some point.

@spyder-ide/core-developers Any comments?

@ccordoba12
Copy link
Member

Restoring Alt+Shift+F11, or perhaps a simpler shortcut, is fine for me.

@jitseniesen
Copy link
Member

Restoring Alt+Shift+F11, or perhaps a simpler shortcut, is fine for me.

@ccordoba12 @dalthviz Next question, how do I assign a default shortcut? Internal plugins set their default shortcuts in spyder/config/main.py, but I don't see a way for this plugin (or other external plugins) to set their default shortcut.

@dalthviz
Copy link
Member

dalthviz commented May 6, 2023

I think spyder-line-profiler sets a shortcut so that could help here! Checking, I think for the shortcut you need to add a shortcuts section in the plugin default config definition, so something like:

https://github.com/spyder-ide/spyder-line-profiler/blob/5bffa70b0ebb3cbaed57626e105deee46d891a2c/spyder_line_profiler/spyder/config.py#L17-L22

And then from the action definition set the register_shortcut kwarg to True, so something like:

https://github.com/spyder-ide/spyder-line-profiler/blob/5bffa70b0ebb3cbaed57626e105deee46d891a2c/spyder_line_profiler/spyder/plugin.py#LL78C1-L86C10

I think the important thing there is to use the name given to the action in the shortcut config definiton. For example, in the case of the line profiler, the action is named run_profiler_action (which is used in the action definition as well as in the shortcut config definition)

@jitseniesen
Copy link
Member

Thanks @dalthviz !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants