logo
 
  1. IT-Security >
  2. Programmierung >
  3. What?s New for Python in Visual Studio (16.3 Preview 2)


ArabicEnglishFrenchGermanGreekItalianJapaneseKoreanPersianPolishPortugueseRussianSpanishTurkishVietnamese

What’s New for Python in Visual Studio (16.3 Preview 2)


Programmierung vom | Direktlink: devblogs.microsoft.com Nachrichten Bewertung

Today, we are releasing Visual Studio 2019 (16.3 Preview 2), which contains an updated testing experience for Python developersWe are happy to announce that the popular Python testing framework pytest is now supported. Additionally, we have re-worked the unittest experience for Python users in this release. 

Continue reading to learn more about how you can enable and configure pytest and/or unittest for your development environment. What’s even better is that each testing framework is supported in both project mode and in Open Folder scenarios.   

 

Enabling and Configuring Testing for Projects

Configuring and working with Python tests in Visual Studio is easier than ever before.

 For users who are new to the testing experience within Visual Studio 2019 for Python projects, right-click on the project name and select the ‘Properties’ option. This option opens the project designer, which allows you to configure tests by going to the ‘Test’ tab.

From this tab, simply click the ’Test Framework’ dropdown box to select the testing framework you wish to use:

Walkthrough of New Testing Features in VS2019 16.3

  • For unittest, we use the project’s root directory for test discovery. This is a default setting that can be modified to include the path to the folder that contains your tests (if your tests are included in a sub-directory). We also use the unittest framework’s default pattern for test filenames (this also can be modified if you use a different file naming system for your test files). Prior to this release, unittest discovery was automatically initiated for the user. Now, the user is required to manually configure testing.
  • For pytest, you can specify a .ini configuration file which contains test filename patterns in addition to many other testing options.

Once you select and save your changes in the window, test discovery is initiated in the Test Explorer. If the Test Explorer is not open, navigate to the Toolbar and select Test > Windows > Test Explorer. Test Discovery can take up to 60 seconds, after which the test discovery process will end.

Once in the Test Explorer window, you have the ability to re-run your tests (by clicking the ‘Run All’ button or pressing CTRL + R,A) as well as view the status of your test runs.  Additionally, you can see the total number of tests your project contains and the duration of test runs:

to show the status of test runs in VS

If you wish to keep working while tests are running in the background but want to monitor the progress of your test run, you can go to the Output window and choose ‘Show output from: Tests’:

show the user how to select the tests output

We have also made it simple for users with pre-existing projects that contain test files to quickly continue working with their code in Visual Studio 2019. When you open a project that contains testing configuration files (e.g. a .ini file for pytest), but you have not installed or enabled pytest, you will be prompted to install the necessary packages and configure them for the Python environment in which you are working:

install and enable pytest infobar

For open folder scenarios (described below), these informational bars will also be triggered if you have not configured your workspace for pytest or unittest.

 

Configuring Tests for Open Folder Scenarios

In this release of Visual Studio 2019, users can configure tests to work in our popular open folder scenario.

To configure and enable tests, navigate to the Solution explorer, click the “Show All Files” icon to show all files in the current folder and select the PythonSettings.json file within the ‘Local Settings’ folder. (If this file doesn’t exist, create one in ‘Local Settings’ folder). Next, add the field TestFramework: “pytest” to your settings file or TestFramework: “unittest” depending on the testing framework you wish to use.

json settings file for tests

 

For the unittest framework, If UnitTestRootDirectory and/or UnitTestPattern are not specified in PythonSettings.json, they are added and assigned default values of “.” and “test*.py”, respectively.

As in project mode, editing and saving any file triggers test discovery for the test framework that you specified. If you already have the Test Explorer window open, clicking CTRL + R,A also triggers discovery.

Note: If your folder contains a ‘src’ directory which is separate from the folder that contains your tests, you’ll need to specify the path to the src folder in your PythonSettings.json with the setting SearchPaths:

add searchpaths settings to json file

 

 

Debugging Tests

In this latest release, we’ve updated test debugging to use our new ptvsd 4 debugger, which is faster and more reliable than ptvsd 3. We’ve added an option so that you can use the legacy debugger if you run into issues. To enable it, go to Tools > Options > Python > Debugging > Use Legacy Debugger and check the box to enable it.

As in previous releases, if you wish to debug a test, set an initial breakpoint in your code, then right-click the test (or a selection) in Test Explorer and select Debug Selected Tests. Visual Studio starts the Python debugger as it would for application code.

debug python tests in VS2019 16.3 P2

Note: everyone that tries to debug a test will find that the debugging does not automatically end when the debugging session completes. This is a known issue and the current workaround is to click ‘Stop Debugging’ (Shift + F5).

There’s also the ‘Test Detail Summary’ view that allows you to see the Stack Trace of a failed test which makes troubleshooting failed tests even easier. To access this view, simply click on the test within the Test Explorer that you wish to inspect and the ‘Test Detail Summary’ window will appear.

Test Detail Summary View for VS2019 Preview 2

 

Try it Out!

Be sure to download Visual Studio 2019 (16.3 Preview 2), install the Python Workload, and give feedback or view a list of existing issues on our GitHub repo.

The post What’s New for Python in Visual Studio (16.3 Preview 2) appeared first on Python.

...

https://devblogs.microsoft.com/python/whats-new-for-python-in-visual-studio-16-3-preview-2/

Externe Webseite mit kompletten Inhalt öffnen

Kommentiere zu What?s New for Python in Visual Studio (16.3 Preview 2)






➤ Ähnliche Beiträge

  • 1.

    Using Visual Studio for Cross Platform C++ Development Targeting Windows and Linux

    vom 629.4 Punkte ic_school_black_18dp
    A great strength of C++ is the ability to target multiple platforms without sacrificing performance. If you are using the same codebase for multiple targets, then CMake is the most common solution for building your software. You can use Visual Studio f
  • 2.

    Making every developer more productive with Visual Studio 2019

    vom 514.49 Punkte ic_school_black_18dp
    Today, in the Microsoft Connect(); 2018 keynote, Scott Guthrie announced the availability of Visual Studio 2019 Preview 1. This is the first preview of the next major version of Visual Studio. In this Preview, we’ve focused on a few key areas, such
  • 3.

    Get to code: How we designed the new Visual Studio start window

    vom 514.32 Punkte ic_school_black_18dp
    By now, many of you may have noticed a very prominent change to the launch of Visual Studio in Visual Studio 2019 Preview 1. Our goal with this new experience is to provide rapid access to the most common ways that developers get to their code: whether it
  • 4.

    Get to code: How we designed the new Visual Studio start window

    vom 514.32 Punkte ic_school_black_18dp
    By now, many of you may have noticed a very prominent change to the launch of Visual Studio in Visual Studio 2019 Preview 1. Our goal with this new experience is to provide rapid access to the most common ways that developers get to their code: whether it
  • 5.

    .NET Core Support and More in Visual Studio 2019 version 16.3 – Update Now!

    vom 446.39 Punkte ic_school_black_18dp
    As we continue to deliver on our mission of any developer, any app, any platform, it’s always an exciting time on the Visual Studio team when we get to launch major features.  Today we’ve released Visual Studio 2019 version 16.3 which contains su
  • 6.

    Announcing Visual Studio Online Public Preview

    vom 443.96 Punkte ic_school_black_18dp
    TL;DR Available beginning at Microsoft’s Ignite conference as a public preview, Visual Studio Online provides managed, on-demand development environments that can be used for long-term projects, to quickly prototype a new feature, or for short-term
  • 7.

    Performance Improvements in Visual Studio 2019

    vom 433.98 Punkte ic_school_black_18dp
    Performance has been a big focus area for Visual Studio 2019, with improvements in many areas, including: Faster Visual Studio startup Faster branch switching experience in Visual Studio C++ open folder – time to IntelliSense improvements Faster C++ compiler
  • 8.

    ‘Tis the Season for the Visual Studio 2019 v16.4 Release

    vom 419.21 Punkte ic_school_black_18dp
    Giving Tree on Microsoft CampusHere in Redmond, glimpses of holiday cheer are filling our campus buildings as the season shifts to twinkling lights and frosty temperatures.  The Visual Studio team is seizing this time as an opportunity to celebrate the comradery
  • 9.

    Android Studio 3.0 Canary 1

    vom 409.17 Punkte ic_school_black_18dp
    By Jamal Eason, Product Manager, Android Just in time for Google I/O 2017, we're providing a sneak peak of Android Studio 3.0 - available to download today on our canary release channel. Android Studio's our official IDE, purpose-built for Android, and we keep increasing our investment. The feature set in Android Studi
  • 10.

    Debug JavaScript in Microsoft Edge from Visual Studio

    vom 403.54 Punkte ic_school_black_18dp
    As you may know, the next version of Microsoft Edge will adopt the Chromium open source project to create better web compatibility and less fragmentation of different underlying web platforms. If you haven’t already, you can try out preview builds of
  • 11.

    Visual Studio 2017 version 15.9 now available

    vom 376.9 Punkte ic_school_black_18dp
    Today, we are releasing Visual Studio 2017 version 15.9. The easiest way to update is directly from within Visual Studio 2017 by selecting Help>Check for Updates or select “Update” from the Visual Studio Installer. You can also download from the Vis
  • 12.

    Uncompyle6 - A Cross-Version Python Bytecode Decompiler

    vom 370.61 Punkte ic_school_black_18dp
    A native Python cross-version decompiler and fragment decompiler. The successor to decompyle, uncompyle, and uncompyle2. Introductionuncompyle6 translates Python bytecode back into equivalent Python source code. It accepts bytecodes from Python versio