Python Tools for Visual Studio and Unit Tests (PTVS) - python

Hopefully someone can give me a hand/few pointers.
So I am currently working on some python scripts and wanted to get some tests written.
My environment is as follows:
MS Visual Studio Community 2015, v.14 Update 3
PTVS v.2.2.4 (2.2.40623.00-14.0)
Python 3.5 64-bit Environment
I have some demo tests written in a test class, which have been appearing and disappearing in test explorer under their own will. Currently, I have none showing in Test Explorer, as per the screenshot below...
Several other people seem to be having issues, and the reasons vary from the test settings processor architecture selected, through to clearing the files in the temp folder etc.
I have been pulling out my hair for a few days now, and am looking for your help, cos i'm now bald.
I've tried removing PTVS and reinstalling, updating to latest, changing the test environment, adding and removing Nunit, incase that was conflicting, etc etc etc.
Any help would be greatly appreciated.
Just managed to get this error message to appear, but I do not think it's correct:
OK, so another update:
I decided that I would download VS CE 2013, and then install PTVS 2.2.3.
I opened the solution there, and the tests loaded instantly, and ran first time...
I know that is not a solution to the problem, but at least I can now run my tests and continue working.
Kindest Regards,

Ok, so it seems that PTVS does not fully work with VS2015 Community Edition.
You can run your scripts etc, but it does not integrate with the test explorer properly.
You will need to download VS2013 CE, and PTVS 2.2.2. Then you can run the test explorer and click run all, which will find all your tests, and run properly. Hope this helps someone, as I spent days trying to get VS2015 and PTVS 2.2.4 working with no luck.

Related

Lego EV3 python intellisense not available?

I've gone through the steps to get started with Lego EV3 and python described here: https://education.lego.com/en-us/support/mindstorms-ev3/python-for-ev3 however visual studio code isn't giving me any intellisense into pybricks.
In order to get anything up and running I'm having to constantly reference the pdf documentation. While that isn't an issue for me personally (2 monitors), it will be come this September when I'm trying to teach a class of 4-6 grade kids how to code on small laptops.
The root of the issue is that deploying the application involves copying all the files onto the robot where pybricks is present and all the imports actually work. However locally in VSCode none of the imports work properly so there's no autocomplete magic.
Anyone know the best solution for getting autocomplete/intellisense up and working?
You have to install python-ev3dev2 package.
You can check the description at the end of this page:
https://github.com/ev3dev/vscode-hello-python
You will either need the source code or you could write .pyi files -- which are basically just typed stub files -- to provide the typing information.
As of 2019, simply installing pybrick stubs did the job for me:
$ pip install pybrick-stubs

Debug python Visual Studio Startup very slow - load module

When start debug from Visual Studio, it takes like 2 minutes to hit the first line of python code. Apparently Visual Studio is busy loading python modules.
python.exe' (Win32): Loaded 'C:\ProgramData\Anaconda3\python.exe'. Symbols loaded.
'python.exe' (Win32): Loaded 'xxxxx'. Cannot find or open the PDB file.
... many more ...
I tried below, no joy:
Tools \ Options \ Debugging
a) Enable Just My Code checked
b) Just-In-Time Debugging - only selected Managed and Script
c) Symbols
unchecked "Microsoft Symbol Servers"
"Load all modules, unless excluded" or "Load only specified modules" (tried both)
https://devblogs.microsoft.com/devops/make-debugging-faster-with-visual-studio/
Reinstall Visual Studio (I tried both Community Edition, Standard Edition)
Reboot my machine three times
Delete all breakpoints
Disable Resharper
Two more observations:
I never had this issue prior to today
Python Interactive Debugger stopped working today - it refuse to print anything!
myDataFrame.head()
print("hello")
Fixed!!
I deleted my Visual Studio solution and project file. Create the python project brand new, all fixed!
Just in case anyone else is looking around,
I also had horrendous debug times (2+ minutes to get to the first line of code).
I was using an Anaconda deployment for numpy/scipy along with pybind11 to interface/debug C code.
I fixed my debug times by using a vanilla deployment of python (3.9.1) and installing the minimal requirements using pip. I believe it was taking so long because visual studio is searching for debug symbols that do not exist. Anaconda does not provide symbol libraries (nor will they according to their forums)
Debug times are now as fast as normal run times (<1s) and I'm no longer dreading hitting the little bug button.
To disable "Enable native code debugging" in the solution properties helped for me.

Python Unit test debugging in VS code

I use VS code for my Python projects and we have unit tests written using Python's unittest module. I am facing a weird issue with debugging unit tests.
VSCode Version: May 2018 (1.24)
OS Version: Windows 10
Let's say I have 20 unit tests in a particular project.
I run the tests by right clicking on a unit test file and click 'Run all unit tests'
After the run is complete, the results bar displays how many tests are passed and how many are failed. (e.g. 15 passed, 5 failed).
And I can run/debug individual test because there is a small link on every unit test function for that.
If I re-run the tests from same file, then the results bar displays the twice number of tests. (e.g. 30 passed, 10 failed)
Also the links against individual test functions disappear. So I cannot run individual tests.
The only way to be able to run/debug individual tests after this is by re-launching the VS code.
Any suggestions on how to fix this?
If anyone is still facing issue related to Unit Test debug and Run related issue in VS Code for Linux or Windows. Please follow these two steps.
Download Latest Build From VSCode Repo Download Ling It will download a .vsix file which is an official extension to be added into next release.
Install the downloaded extension (.vsix) by using command code --install-extension myextension.vsix For more detail Read This How to install Click Here
I also faced a lot of issues and struggled a lot. So finally I raised an issue in the official GitHub repository. Check here Which helped me to solve the issue.
This was a bug in Python extension for VS code and it is fixed now.

Visual Studio 2017 not recognising errors in code

I just installed the Python development workload for VS 2017 but the editor shows none of the red squiggly underlining for syntax errors that I'm used to seeing with C# on VS, nor any entries in the error list. If I try to run the code with errors, it warns me there are errors in the code but does not specify what they until exceptions are thrown from running.
I've tried reinstalling the workload and looked through every available option under the Tools/Options tab but can find nothing about syntax errors. Any fixes detailed for earlier versions of VS no longer seem to apply, what am I missing?
I had exactly the same problem using the simplest project from the VS Python tutorial.
The fix was to upgrade from VS 15.4.1 to 15.5.
Walt
I have had the same thing happen to me. Though this was actually with a C# application. I noticed Visual Studios stopped detecting the errors after adding a few NuGet references and doing some manual modifications of the project files. I noticed that this was only happening on this one project. All the other projects I worked on did not seem to have the same issue.
I was able to get it to start working again by creating a new project, moving my code over, and adding the references back one by one. For this situation, it looked as if a corrupt project file or bad reference was to blame even though the project would compile and run correctly.
Does this issue exist in other programming languages/projects?

editor showing errors with Aptana Studio 3 after update

I have used Aptana Studio 3 for the programming of python for quite a while and never had problems. But after the update today (the version now is 3.5.0.201401092130-09012014213131), the editor stopped recognizing a lot of code (it marks functions like len, int, float and even things like None or True as errors).
I still can run all my programs without any problems so i figured that this must be an issue with an editor. Any ideas what the problem might be?
Not really a solution, but this workaround worked for me. After reverting to a previous version (3.4.1 in my case), the behavior I described above still persisted. But after I switched between the PyDev and the Web perspective a couple times, the editor went back to the normal behavior (the perspective switching didn't do the trick for version 3.5).
When I talk about version reverting, I don't mean the build in option (I tried it, but it just showed an error). I deleted the Aptana Studio 3 installation folder and downloaded the 3.4.1 version from this website.

Categories

Resources