Error in Running Django tests in visual studio - django

My tests are running fine in terminal but while trying to run tests in visual studio i got error of :
Error of django.core.exceptions.AppRegistryNotReady: Apps aren't loaded
My Visual studio Folder settting file is:
"python.pythonPath": "/home/aditya/Maximl/Blast4/Server/syncopsenv/bin/python3.6",
"python.unitTest.pyTestEnabled": false,
"python.unitTest.nosetestsEnabled": false,
"python.unitTest.unittestEnabled": true,
"python.unitTest.debugPort": 3000,
"python.unitTest.autoTestDiscoverOnSaveEnabled": true,
"python.unitTest.pyTestArgs": ["."],
"python.unitTest.unittestArgs": ["-v", "-s", ".", "-p", "*test*.py"]
}

Visual Studio doesn't go via python manage test. So you need to explicitly call django.setup() first. See here

Related

Visual Studio 2017 JavaScript Language Service has been disabled

While editing JavaScript source files in Visaul Studio 2017, the following error keeps occuring:
The JavaScript language service has been disabled for the following project(s): ...
Even if I disable the JavaScript language service entirely, the error keeps occuring. Why is this happening and how do I stop this error message from displaying all the time? Can I disable the JavaScript language service entirely?
The solution to the problem was simply to use a tsconfig.json file, even though there were only JavaScript files in my solution.
I've just used the following tsconfig.json file in the root of the project:
{
  "compileOnSave": true,
 "compilerOptions": {
    "noImplicitAny": false,
    "noEmitOnError": true,
    "sourceMap": true,
    "target": "es2015",
    "module": "amd",
    "allowJs": false,
    "allowSyntheticDefaultImports": true
  },
  "exclude": [
    "lib",
    "node_modules"
  ]
}
open 'developer command line tool for visual studio'. run :
devenv.exe /resetuserdata

How do I turn off JSLint in Visual Studio 2017?

I loaded up an older aspnet mvc project in Visual Studio 2017, and I can't build it because thousands of warnings/errors from jslint are telling me that the jQuery package has bad bracket placement, among many other things. Frankly, I don't care about any of the errors from jslint, least of all the jQuery errors.
I can't find any options for jslint in the GUI.
Right-clicking on the project gives no jslint context menu
It doesn't seem to exist in Tools > Options
I tried this solution, of turning off EsLint, but that did nothing.
JSLint.Net is a NuGet package. You can configure it via a JSLintNet.json settings file (at the end of that page it says there's a settings dialog, but I can't find it in either VS 2015 or VS 2017.) Or you can uninstall the package thru the Project > Manage NuGet Packages... menu.
Don't know about VS2015 or 2017, but in 2019 the settings file JSLintNet.json can be created in the project folder and then you can set
"runOnBuild": false,
"cancelBuild": false
Here's my complete file:
{
"ignore": [
"\\www\\js-lib\\*.*"
],
"options": {
"predef": {
"$": true,
"document": true,
"login": true,
"setup": true,
"window": true,
"popup": true
},
"plusplus": true,
"unparam": true,
"white": true
},
"output": "Warning",
"runOnSave": true,
"runOnBuild": false,
"cancelBuild": false
}

Visual Studio Code: No tests discovered, please check the configuration settings for the test

I am using visual studio code and want to run some test. I was using PC where it was working perfectly. I changed my system and copied all the files in same directory as these were before in old pc. But now visual studio does not recognizes the tests and this message keeps appearing up.
In settins.json under Workspace Settings I have,
{
"python.linting.pylintEnabled": false,
"python.unitTest.unittestEnabled": true
}
You should check your start directory and your matching pattern (-s and -p options).
https://docs.python.org/3/library/unittest.html#test-discovery
This configuration fixed it for me.
"python.unitTest.unittestEnabled": true,
"python.unitTest.pyTestEnabled": false,
"python.unitTest.nosetestsEnabled": false,
"python.unitTest.unittestArgs": [
"-v",
"-s",
"your_tests_directory",
"-p",
"test_*.py"
]
You can also play with the command line if you prefer it that way before setting the vs code configuration.
python -m unittest discover -v -s your_tests_directory -p test_*.py

Turning off "Language Service Disabled" error message in VS2017

We are getting the following "Error" message in our MVC web application in Visual studio 2017 Enterprise.
The language service is disabled for project 'C:\Work\Blackhawk
Platform\Platform-DEV-Branch\BlackhawkViewer\BlackhawkViewer.csproj'
because it included a large number of .js files. Consider excluding
files using the 'exclude' section of a 'tsconfig.json' file.
I have tried turning off the Language service in the options but this does not turn the message off:
This is a rather large web application. Is there a way to turn this message off without disabling any files in the tsconfig.json file as it suggests?
To solve this issue do the following:
Create file in root directory of your project and call it tsconfig.json
Add this:
{
"compilerOptions": {
"allowJs": true,
"noEmit": true,
"module": "system",
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": true
},
"include": [
"scripts"
],
"exclude": [
],
"typeAcquisition": {
"enable": true
}
}
Please have a look at the below two links for tsconfig.json explanation, because you may still need to change it according to your setup. This is the only way that worked for me. I hope that will help.
https://www.typescriptlang.org/docs/handbook/tsconfig-json.html
https://developercommunity.visualstudio.com/content/problem/8148/javascript-intellisense-not-working.html
This helped me. You can have a try.
Go to Tools -> Options -> Text Editor -> JavaScript/TypeScript -> Language Service -> General
and uncheck the box: "Enable the new JavaScript language service.
I have found a solution for this problem.
I reset my userData using:
devenv.exe /resetuserdata
Since doing this the JavaScript settings seem to have persisted and I no longer get the language service error above.
TAKE NOTE: This will reset all your user data and customisations.
In My case I just disable TypeScript support on Visual Studio:
Tools > Extensions and Updates > TypeScript for Microsoft Visual Studio > Disable
After that, just restart Visual Studio, and you are good to go.
Hope this will help,
I had the same problem after migrating Ionic 1 project from VS2015 to VS2017, first I executed git clean -fxd as sugested above and added this content into tsconfig.json in my ionic project.
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5"
},
"exclude": [
"node_modules",
"www",
"bower_components"
]
}
I solved this problem with following solution:
When you have a JavaScript file that is included in the project.csproj file but isn't in the project folder, this error occurred.
For example I have a .csproj file like below:
<ItemGroup>
<Content Include="Scripts\Test.js" />
</ItemGroup>
The Test.js is included in the .csproj file, but it isn't in the Scripts folder:
Delete the <Content Include="Scripts\Test.js" /> line from the .csproj file and rebuild your project
Solution that worked for me:
Go to C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE>.
Open command prompt as admin in current folder
Ran devenv /Setup
Ran devenv /ResetSkipPkgs
For me is helping the next solution. I've create a tsconfig.json file in root of the my project with "disableSizeLimit": "true" option.
So, my tsconfig.json file is:
{
"compilerOptions": {
"disableSizeLimit": "true"
},
"exclude": []
}
If none of suggested methods worked, try:
npm install -g typescript#latest
and then
Install the latest version of TypeScript for Visual Studio on Get TypeScript.

Experiencing "DEP3000" error when trying to run WinRT unit tests

I am experience this strange error trying to run unit tests for WinRT from Visual Studio 2012.
Error: DEP3000: Attempts to stop the application failed. This may
cause the deployment to fail. App Packages may only be shutdown as
part of a Visual Studio build operation
I don't understand at all what that could mean? I've tried restarting my computer and reinstalling developer license. How I reproduce it is I just create a new empty unit test project from the Visual Studio template. I don't touch the project at all. But, when I try to do Run Tests on it, it just says pending for a a while and then spits out that error
How do I fix this?
Specs: Windows 8 Enterprise 64bit, Visual Studio 2012 with Update 2
Also, I've seen this question about VS2012RC, but the answer doesn't seem to apply. I've tried every configuration of this there is and nothing works past this error
I had same problem when I applied VS upgrade2 AND used Resharper 7.1.1 to run the unittests. Turns out you need to upgrade Resharper to 7.1.3 -- or run the tests with the VS test explorer.
You can just try using XUnits App:
https://channel9.msdn.com/Shows/demooftheday/xunit-in-uwp
With this, test will run on XUnit's test app, not in VS Test Explorer.
In my unit test project's project.json
{
"dependencies": {
"Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0",
"xunit": "2.1.0",
"xunit.runner.devices": "2.1.0" }, "frameworks": {
"uap10.0": { } }, "runtimes": {
"win10-arm": { },
"win10-arm-aot": { },
"win10-x86": { },
"win10-x86-aot": { },
"win10-x64": { },
"win10-x64-aot": { } }
}
Then go to the XAML file in the unit test project named UnitTestapp.xaml and change it to
<ui:RunnerApplication
x:Class="UnitTestProject1.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UnitTestProject1"
xmlns:ui="using:Xunit.Runners.UI"
RequestedTheme="Light">
</ui:RunnerApplication>
And of course, in the code behind:
sealed partial class App : RunnerApplication
{
protected override void OnInitializeRunner()
{
AddTestAssembly(GetType().GetTypeInfo().Assembly);
InitializeRunner();
}
partial void InitializeRunner();
}