Run Django doctests from PyCharm - django

PyCharm's test runner does a great job with unit tests, likewise the run command contextually recognizes if you are in a unit test in a helpful way. Is there any way to get it to do the same with doctests running within the Django environment? (As opposed to Python doctests, which PyCharm supports -- but which don't work for a Django project because the run environment isn't set up correctly.)

I don't believe it's possible.
My approach has been to create a "Django tests" configuration and specify a target, custom settings and options. (Menu: Run -> Edit Configurations... -> Click on the + icon to create a new configuration) I do something like this when I'm working in a particular module and simply change the settings appropriately to get the set of tests you want.
Not as nice as having it off the right-click run menu unfortunately.

Related

Run AHK script as admin on startup

I have four AHK scripts which run on startup, as they have shortcuts placed in my startup folder. How can I make them run as admin?
What I've tried:
I've tried changing their properties to be run as admin, but they just don't run (when I do that).
I've tried changing their shortcuts' properties to be run as admin, but they too just don't run (when I do that).
I've looked at this reddit post on the topic, but I don't know how to implement that code in the scripts.
I've tried creating a basic C++ application which runs them with system("start path\\to\\script"), but it wouldn't compile.
In case it matters, the scripts in question are ahk-active-screenshot, CtrlAlt_Switch.ahk, Kill.ahk, and a modified version of this search script.
You can allow the script to automate administrative programs without running as admin, here're the required steps:
When installing AHK, check the "Add 'Run with UI Access' to context menus" option.
After installation, find AutoHotkeyU64_UIA.exe on your disk.
Open the .ahk script's properties, change the "Open with" option to the AutoHotkeyU64_UIA.exe you just found.
Create a shortcut to this script.
Open %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup in the file explorer.
Move that shortcut to this folder.
And you're done.
How does it work?
The "Add 'Run with UI Access' to context menus" option provides a workaround for common UAC-related issues by allowing the script to automate administrative programs without running as admin.
Reference: Run with UI Access.
Find the UIA version of autohotkey on your machine. For me it is at C:\Program Files\AutoHotkey\AutoHotkeyU64_UIA.exe.
In your startup folder, create a new shortcut (probably one for each of the scripts you want) as follows (replacing paths as appropriate):
Target: "C:\Program Files\AutoHotkey\AutoHotkeyU64_UIA.exe" "D:\path\to\script.ahk"
Start in: "C:\Program Files\AutoHotkey"
This launches your script as an admin using the UIA version of AHK on startup.

Clojure pedestal.io code is not resolved in IntelliJ

I have a small application of Clojure and Pedestal that I grabbed from pedestal.io tutorial. It works fine in the terminal. When I open it in IntelliJ some "cannot be resolved" tips are appearing. And some code parts are getting a beige background.
I have Cursive plugin installed. The code is executed by boot repl. Is any way to resolve full code by IntelliJ? If so, which settings?
Update
"Indexed Maven Repositories" field
Check your settings to make sure both Clojars and Maven repos are indexed:
Navigate to:
File
-> Settings
-> Build, Execution, Deployment
-> Build Tools
-> Maven
-> Repositories
And make sure it looks like the above picture. If necessary, highlight both the Maven & Clojars repos and click "Update", then "OK" (you don't need to wait for it to finish as it is a background process).
Also, it is frequently helpful to do
File
-> Invalidate Caches / Restart
Then it will resolve correctly:
Update #2
OK, I see you have a boot project. I have a lein project, and Cursive populated my list automatically (from project.clj I assume). Two ways forward:
Search the docs, SO, & Cursive mailing list for boot info. The Cursive author is very responsive to items on the mailing list:
If the above doesn't work, maybe convert it to a lein project just to make Cursive/IntelliJ happy. You can still run it as a boot project from the command line (or however you normally use boot).
For more info, see also this question: IntelliJ IDEA: "Indexed Maven Repositories" list - how to add remote maven repository in this list?
and the reference: http://maven.apache.org/settings.html#Repositories
Update #3:
OK, just found this boot Cursive info, which looks good: https://github.com/boot-clj/boot/wiki/For-Cursive-Users

Can I run/debug files with babel-node in WebStorm?

I know there are Run/Debug configurations in WebStorm, but I don't know how to configure the context menu (when I right click in a file, it has Run... and Debug... in the menu, but I can't find where to configure this).
Run configurations are created via Run | Edit Configurations... : press +, choose Node.js, in created configuration specify babel-node as Node Interpreter:
But note that debugging doesn't work well when using it. I'd strongly recommend using -r #babel/register Node.js parameter instead - see comments in https://youtrack.jetbrains.com/issue/WEB-21949

PyCharm coverage only measures test directory for a GAE app with Selenium tests

I'm developing a GAE app in Python using the PyCharm IDE. I have developed an initial set of Selenium WebDriver unit tests, which are in directory "test", with "test" at the top level of the project directory. Note that my tests do not directly call the GAE modules. They only utilize Selenium, which in turn runs the app thru a browser.
When I use menu option "Run 'Unittests in test' with coverage", I get a report showing coverage within directory "test", and also the colors show up in the left margin for the Python modules in "test". The information looks accurate. Very cool!
However, the rest of the files in my project show "not covered", even though the tests exercise a lot of that code via Selenium remote control of a browser.
In settings, I've tried checking "Use bundled coverage.py" and, after running sudo pip install coverage, I've also tried unchecking "Use bundled coverage.py". My results are the same either way.
Is it possible that you simply cannot obtain coverage of a GAE app being exercised via Selenium?

Unable to execute unit tests in a maven project from within intellij

I have inherited a legacy project with 100s of tests, and dependencies defined within the pom.
All of the tests run when I execute a mvn clean install from the command line, but when I try to execute one of these tests in debug mode from within Intellij i get the following error.
java.lang.NoClassDefFoundError: Could not initialize class
How can I get intellij to recognise these dependencies when trying to run a test in debug mode from the ide?
I managed to solve this by simply changing the working directory location in the Run configuration to point to the correct classpath location. The default location had been taken from a parent project.
It would be very convenient if one was able to debug tests from within IntelliJ. I have run into similar issues with my massive project and have found a workaround for it.
When wishing to debug a test, I have often found it useful to use a remote debugging session like so:
mvn -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -Xnoagent -Djava.compiler=NONE" -Dtest=com.autofunk.TheFunkImplTest test -DfailIfNoTests=false
You can then attach to the above using a remote debug session from within IntelliJ on port 8000.
Therefore, when debugging tests I first check to see whether a simple debug from within Intellij works. If not, I run the above and then attach to it using a debug configuration like so:
IntelliJ execute unit tests without mvn command.
a IntelliJ plugin: MvnRunner
You can run tests using the maven project window in IntelliJ
View - Tool Windows - Maven Projects
Then under the project or module you wish to test open the lifecycle goals and click test.
This will run the currently configured test goal. Now the report is logged into the target directory
I use
https://github.com/destin/maven-test-support-plugin
to view the test results.
You can access this screen once the plugin is installed from the Project window again right click on the projects root and select "Show Test Results" (should be below the maven icon)
Good luck