PyDev, PyUnit Usage Questions - python-3.x

In the PyUnit view in Pydev...
Suppose the view currently shows 5 tests, 1 of which fails.
When I right click on the failed test, and then run it (with either Run or Debug), all the other tests disappear from the view. How do I stop it from removing all the other tests?
Next question.....
Also, Pydev then creates a run configuration for the test that I just ran. Which means that if I right click on the test module in the PyDev Package Explorer, and then try to "Run As" "Python Unit Test", I then have to select which run configuration. How do I stop it creating a new run configuration?

When you right-click a failed test and run it, you did a new run configuration that just ran it alone (so, you get the results just showing that one).
What is implemented is that you have a 'pin' icon in the pyunit view. You can click it to 'bookmark' the run, so, when you press the 'reload', which is the icon in the right of the pin, it'll reload those results (or you can manually choose the results from any run from the test run history dropdown).
As for running, there's no way to stop it from creating a new run configuration, but what you can do is just re-run the last one with Ctrl+F11 (provided you configured it properly as explained in http://pydev.org/manual_101_run.html).
You can also access old runs with Alt+R, T > number from 1 to 9 an old configuration you want to run.

Even though it is possibly not the exact approach you may expect, one option is to start the Unittest from the command line and attach the debugger by RemoteDebugServer via 'pydevd.py'.
This is now a fully automated option of ePyUnit which includes the automation of remote debugging with PyDev and Eclipse by 'pydevd.py'. This works seamlessly for the 'subprocess' call as well as independently started command line processes.
See:
https://pypi.python.org/pypi/epyunit
https://pythonhosted.org/epyunit/
For basics of remote debugging:
http://www.pydev.org/manual_adv_remote_debugger.html
Also enhanced unittest integration into PyUnit.
Comments and fixes are welcome.
Have fun..

Related

Separate Build for every file/tab in Sublime Text

When you run Build System is Sublime by default it creates a bottom pop-up that is bound to that sublime window. When you change to other tabs bottom pop-up will still stay for the Build that you have started.
I would like to have separate Build/Build pop-up for every tab that is opened in that window. For example; there are two tabs open, file01 and file02. I run Build System for file01 and while its running I switch to other tab, file02, and there is no Build pop-up. I can edit file02 and also run build on it separately while build on file01(tab one) is running. Also starting and stopping Builds for for different files will not affect Builds for other files/tabs. Essentially every tab in a window would have separate Build System and Build pop-up.
The short answer to your question is, there is no out of the box way to do this; by design build systems are executed in the context of a window and not a file tab within a window.
The longer form answer is that builds are executed by an instance of a WindowCommand, which is a command that is specific to a window. That command can do anything that it likes in order to drive the build.
By default, the command used is named exec, and its implementation can be found by using the command palette by using View Package File and looking at Default/exec.py.
The implementation that ships with Sublime follows the rule that there is one build per window, and so when you trigger a build if one is already running, it is cancelled in favor of the new one.
To do what you want, you would need an implementation of what that command does that instead tracks the build per tab instead of per window. Such a command would need to cover all of the edge cases inherent in this as well, such as the commands that navigate through errors not working if there is more than one build result, or what happens if you close a file while a build is running, etc.

How keep tests shortcuts/icons once `auto-run` is switched off from the extension sidebar?

Currently Jest in my VSCode uses the --watch parameter (I use the Orta.vscode-jest extension), which mean when I save a file, it will run all tests in uncommitted files.
It's a good default behavior but sometimes my upcoming commit may imply multiple files and I don't want to waste 75% of my time and resources on tests I don't to focus on.
After reading documentation, I found I can turn off the auto-run (see arrow below), so now when saving nothing happens, and I was expecting a way to trigger manually the test I want.
Unfortunately once done it's like if the extension was totally shut down. See below, I have no longer the ability to run tests through the extension.
Do you know a way to solve this? Keeping icon buttons to trigger manually specific tests?
I saw some homemade solution https://stackoverflow.com/a/55279902/3608410 (see Running a selected Jest test in Visual Studio Code) but I feel it's weird since we have a powerful extension already installed.
(maybe I missed something...)
Thank you,
Didn't see that before but if doing a right click in the test file where needed, in the menu I'm able to run a specific test, handy!

How do I get npm to run in terminal?

I'm tasked with creating a simple calculator application for entry to a programming course. I'm having issues with Terminal :(
I'm not looking for an answer to my overall task, I just want to know why Terminal wont RUN!! What am I doing wrong?
Steps as follows:
Create a directory that you will keep your Calculator application in. Call it
something sensible, like "Calculator".
Open up a command prompt and navigate to your calculator directory
Run npm init to create a new Node.js project. Use the default answer to every
question it asks you (just press "Enter") - don't worry if you don't understand
what all the questions mean!
If it doesn't do anything after the final question "Is this ok?", double-check
there's a file in the folder called package.json . If it's there, everything went
smoothly and you can exit the npm init process by typing in the console
Ctrl + C .
So my problem is... when I run npm, all that happens is my Mac asks if Terminal can access or change files in my system, I click yes, then Terminal doesn't do anything from there, no questions etc I just get:
I can't see package.json, so I take it it hasn't worked properly? How can I fix this to move on?
I'm using zsh on terminal.
Well, first off. What ide do you use? (Personally I like Visual Studio Code).
I'm not sure what the short command is for you to open up the terminal but just google it. Otherwise, you can click "Terminal" on the very top and open a new terminal.
When you do this, you will get a new window at the bottom of your screen. This window has some tabs, make sure you are in the terminal tab.
While there, type "npm init".
This will give you your package.json-file.
If you want to use your terminal for outputs I recommend you get nodejs too.

Does Intellij automatically update classes you've made changes to while in Debug mode?

I know that for css, html, and gsp files you can just refresh the browser without having to rebuild the application in order to see your updated changes. If you're stepping through code in debug mode, and make a change for a groovy or class file, do you have to rebuild the application in order to see the change?
IntelliJ does not update the classes in your running application automatically. You need to compile them manually (this will not be a full project rebuild - IntelliJ will build the project incrementally and compile only the changed classes and the code that depends on them), and then IntelliJ will offer you to reload the changes (which may fail if the changes you made aren't supported by the Java hotswap).
Note that some Web frameworks may be able to reload the changed classes automatically, independently of whether you're running your code from IntelliJ or not.
Say you're stopped on a break point, and want to edit the source code of the method you're in. Make the edit, save it, then run > Reload Changed Classes. Then, in the debugger controls, Drop Frame. Without dropping the frame, you won't execute the your newly recompiled method body.
By default, there's no keybindings for these 2 commands, but you can create them via the KeyMap in the settings (ctrl + alt + s). Even better, you can make a macro that will execute both these commands for you.
I wish it was easier and automatic, like in eclipse, but oh well.

Debugging impossible when gtk dropdown active

I have a window, with several Gtk-2.0 widgets. One of them is a GtkEntry, with the corresponding GtkCompletion connected.
I need to debug the code called when a selection ('match' event) is made in the dropdown shown by the GtkCompletion. So I set a breakpoint, activate the selection, and the entire desktop hangs. The only form I found to get out is Ctl-Alt-Backspace, and delete the gdb instance.
When this happens, the entire windows manager remains as if the dropdown is still active - only responds to Ctl-Alt functions, like Ctl-Alt-F2.
I tried the --sync commandline option, but that didn't make any difference. Though there seem to be some (rather complicated) solutions such as running a nested Window server, or debug remotely, I can't imagine there isn't a more elegant solution.
Any suggestions?
I do this all the time.
You need to grab another laptop, or a console on another server, and ssh into your primary desktop/laptop. Start your GTK application on your main desktop/laptop, then attach gdb to it from your connection from your other laptop/machine.
Then, you will run your gtk application on your main screen, and debug it from a separate connection, without interfering with your primary display.
EDIT: I see that you already considered remote debugging, but in my experience it's really not that difficult. I just have another laptop on my desk, next to me, to debug my X applications.

Resources