Debugging nosetest test in Pycharm doesn't show output - debugging

I'm trying to debug a test using nosetests in PyCharm. I need to stop at a breakpoint and do some interactive debugging using the PyCharm debug console. However, whenever I type anything at the debug console prompt, nothing is printed; I just get a new prompt. The debug console works perfectly with pytest, but I need to use nosetests for this particular test. How can I get the console to work correctly?

Most likely your nose runner suppressing stdout. Try running nosetests with -s

Under the "Tools" menu, select "Edit Configurations." In the dialog, expand "Python tests" and select the nosetests you are running. Add "-s" as an "Additional Argument".

Under the Tools menu, select Edit Configurations. In the dialog, expand Python tests and select the nosetests you are running. On the Configuration tab, under the Nosetests section, make sure the checkbox in front of Params is checked and then add -s as a parameter to it. Apply and Save.

Related

Significance of "Execute in terminal" option in IntelliJ IDEA

I am trying to create a shell script run configuration with existing system utilities. Here's a test Run Configuration for printing the present working directory.
Output for this Run Configuration :
When I uncheck the Execute in terminal option in the Run Configuration, I get this output :
What is the significance of this option and is it possible to make it work with the Execute in terminal option unchecked?
IDE version : IntelliJ IDEA 2020.3 (Community Edition), Build #IC 203.5981.155
OS : Ubuntu 20.04.1 LTS
IntelliJ comes bundled with a terminal plugin simply called "Terminal".
When you have the plugin enabled, and the checkbox "Execute in the terminal" checked, the run config will be run inside the "Terminal" window, within your usual interactive shell.
With the checkbox unchecked, it runs in the "Run" window instead.
When you have the plugin disabled, the checkbox makes no difference.
Also note that in newer versions of IntelliJ (I'm on 2022.2.3 currently), there is a new option to run "Script text" instead of a script file. With that option, you don't have to fiddle around with bash -c for running a single command. For your example, just Script text: echo "$PWD" works.

Not able to type in terminal in vs code

Have installed angular CLI via node js command prompt. However, when I launch terminal in VS code, it doesn't allow to type only. PFA screenshot
PFB terminal setting screenshot
Able to run ng commands from node js command prompt outside vs code.
If your problem is not related to default shell in your terminal. Then you check windows settings. Follow the steps -
Open VSCode file location
Go to Compatibility tab in VSCode properties window
Unchecked Run this program in compatibility mode for: option
see the attached files. Try with this solution, it might help you.
This worked for me:
Remove settings file.
Click on view/terminal.
Select default shell.

How to debug code running from terminal in pycharm

I am running my code in Pycharm from Terminal. Is it possible to debug the code and put breakpoints inside the code during a run from terminal?
I don't know anyway to do this through the terminal, but the way I currently do it is:
Run > Edit Configurations > Add new configuration (the green + button)
Choose Python
Fill out Script path, Parameters, and other configuration fields.
Debug the newly added configuration. (Run > Debug...)
With the right configuration the result should be the same as running the script in a terminal.
I find the above process a little tedious. A PEP 553 breakpoint() might be nicer. It requires Python 3.7 and is not implemented yet. See the related issue.
Even if the program is started outside of PyCharm, we can attach PyCharm debugger to it.
Go to Run -> Attach to process.
This will show a list of python process that are currently running on the system. Select the appropriate process from it.
Now PyCharm debugger is connected to that process. We can add breakpoints and debug it.
There is a way using python console.
To run it: Tools -> python console .. or you can find it at the bottom of the IDE.
Then press on 'Attach debugger' line in the following picture:
Add a breakpoint in your code and then pass the file name to the cosole, like: %run my_file.py

Unable to hit breakpoints in MonoDevelop

On my archlinux system I did a fresh installation of:
mono 3.0.7
monodevelop 4.0.8
monodevelop-debugger-gdb 4.0
When I debug an application the debugger doesn't stop on the breakpoints, even not on the System.Diagnostics.Debugger.Break (); code.
And an error windows is displayed with the following message :
Could not connect to the debugger
Does anyone know how to fix it?
This is due to a recent gnome-terminal change. Recent gnome-terminal no longer accepts the --disable-factory argument.
Install the xterm package, then in a gnome-terminal session do the following:
$ unset GNOME_DESKTOP_SESSION_ID
$ monodevelop
This will cause monodevelop to use xterm as its external terminal and all should be well.
As a workaround untick the "Run on external console" checkbox in your running project settings. You can find this option in the "Run" tab from the settings pane.
Another factor which will cause break points to not be hit is if you don't have "Emit debugging information" button set.
You'll find this setting in "Project" tab then at the bottom of the menu " Option". Then look for "Build" tree branch then "Compiler" option. The checkbox for "Emit debugging information" is here.
I had a similar problem - breakpoints was not triggered while checkbox "Use MSBuild build engine" was checked in the project properties.

GDB command file in XCode

I'd like to add a file to my project that has a list of gbd commands and load that into GDB within xcode at any breakpoint. Looking at GDB documentation I see the "source" commmand, but it is unknown within xcode's gdb. Has anyone had success doing this?
source -f commandfile.gdb
Thanks,
The source command appears to work although no options are supported if you are really using gdb as the debugger. In the debug console make sure it says "(gdb)" as the prompt. The default debugger now is LLDB instead of GDB. You can change this under Product -> Edit Schemeā€¦ and select the "Info" tab at the top. The "Debugger" popup will present you with GDB or LLDB.

Resources