Right-click project, select Add > New Item …, then select "Python Unit Test" followed by "Add".
Add test_1.py file with code
import unittest
class Test_test_1(unittest.TestCase):
def test_A(self):
self.fail("Not implemented")
if name == 'main':
unittest.main()
4. Set Test framework as "unittest" in python project properties page.
5. Open TE with the Test > Windows > Test Explorer menu command
6. Right click and select run.
**Expected behavior**
No error.
**Additional context and screenshots**
![unexpectederror](https://github.com/microsoft/PTVS/assets/82852072/9032e419-96f8-4cc3-a388-e0700174d40d)
## Output
<details>
<summary>Output for <code>Tests</code> in the <code>Output</code> panel (<code>View</code>→<code>Output</code>, change the drop-down the upper-right of the <code>Output</code> panel to <code>Tests</code>)
</summary>
<p>
Log level is set to Informational (Default).
Source code repository not available. Some features may not work as expected.
Connected to test environment '< Local Windows Environment >'
Test data store opened in 0.015 sec.
========== Starting test discovery ==========
Starting unittest discovery for the PythonApplication13 project. This can take up to 60 seconds.
cd C:\Users\vting\source\repos\PythonApplication13\PythonApplication13\
set PYTHONPATH=C:\Users\vting\source\repos\PythonApplication13\PythonApplication13\
C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64qbz5n2kfra8p0\python3.9.exe C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\PREVIEW\COMMON7\IDE\EXTENSIONS\MICROSOFT\PYTHON\CORE\PythonFiles\testing_tools\run_adapter.py discover unittest --output-file C:\Users\vting\AppData\Local\Temp\tmp4413.tmp -- . test*.py
========== Test discovery finished: 1 Tests found in 2.6 sec ==========
System.AggregateException: One or more errors occurred. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: element
at MS.Internal.Media.VisualTreeUtils.AsNonNullVisual(DependencyObject element, Visual& visual, Visual3D& visual3D)
at System.Windows.Media.VisualTreeHelper.GetChildrenCount(DependencyObject reference)
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.FindDescendant[T](DependencyObject parent)
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.TryFindSummaryDockPanel(DockPanel& summaryPanel, TextBlock& titleBox)
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.d22.MoveNext()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.get_AskCopilotBtn()
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.d19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.<>cDisplayClass18_0.<b0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread()
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.AppendContent(ISummaryGenerator summaryGenerator, String indent, CancellationToken cancellation)
at Microsoft.VisualStudio.TestWindow.Logging.ILoggerExtensions.CallInternalWithLogging(IInternalLogger log, Action action, Boolean shouldThrow)
---> (Inner Exception #0) System.ArgumentNullException: Value cannot be null.
Parameter name: element
at MS.Internal.Media.VisualTreeUtils.AsNonNullVisual(DependencyObject element, Visual& visual, Visual3D& visual3D)
at System.Windows.Media.VisualTreeHelper.GetChildrenCount(DependencyObject reference)
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.FindDescendant[T](DependencyObject parent)
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.TryFindSummaryDockPanel(DockPanel& summaryPanel, TextBlock& titleBox)
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.d22.MoveNext()<---
Building Test Projects
========== Starting test run ==========
cd C:\Users\vting\source\repos\PythonApplication13\PythonApplication13\
set PYTHONPATH=C:\Users\vting\source\repos\PythonApplication13\PythonApplication13;C:\Users\vting\source\repos\PythonApplication13\PythonApplication13\
"C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64qbz5n2kfra8p0\python3.9.exe" "C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\PREVIEW\COMMON7\IDE\EXTENSIONS\MICROSOFT\PYTHON\CORE\visualstudio_py_testlauncher.py" -t test_1.Test_test_1.test_A -r 55532
Connected to socket
Connection event fired
========== Test run finished: 1 Tests (0 Passed, 1 Failed, 0 Skipped) run in 250 ms ==========
System.AggregateException: One or more errors occurred. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: element
at MS.Internal.Media.VisualTreeUtils.AsNonNullVisual(DependencyObject element, Visual& visual, Visual3D& visual3D)
at System.Windows.Media.VisualTreeHelper.GetChildrenCount(DependencyObject reference)
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.FindDescendant[T](DependencyObject parent)
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.TryFindSummaryDockPanel(DockPanel& summaryPanel, TextBlock& titleBox)
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.d22.MoveNext()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.get_AskCopilotBtn()
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.d19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.<>cDisplayClass18_0.<b0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread()
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.AppendContent(ISummaryGenerator summaryGenerator, String indent, CancellationToken cancellation)
at Microsoft.VisualStudio.TestWindow.Logging.ILoggerExtensions.CallInternalWithLogging(IInternalLogger log, Action action, Boolean shouldThrow)
---> (Inner Exception #0) System.ArgumentNullException: Value cannot be null.
Parameter name: element
at MS.Internal.Media.VisualTreeUtils.AsNonNullVisual(DependencyObject element, Visual& visual, Visual3D& visual3D)
at System.Windows.Media.VisualTreeHelper.GetChildrenCount(DependencyObject reference)
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.FindDescendant[T](DependencyObject parent)
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.TryFindSummaryDockPanel(DockPanel& summaryPanel, TextBlock& titleBox)
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.d22.MoveNext()<---
Describe the bug
Python from Microsoft Store.
Steps to Reproduce
class Test_test_1(unittest.TestCase): def test_A(self): self.fail("Not implemented")
if name == 'main': unittest.main()
Log level is set to Informational (Default). Source code repository not available. Some features may not work as expected. Connected to test environment '< Local Windows Environment >' Test data store opened in 0.015 sec. ========== Starting test discovery ========== Starting unittest discovery for the PythonApplication13 project. This can take up to 60 seconds. cd C:\Users\vting\source\repos\PythonApplication13\PythonApplication13\ set PYTHONPATH=C:\Users\vting\source\repos\PythonApplication13\PythonApplication13\ C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64qbz5n2kfra8p0\python3.9.exe C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\PREVIEW\COMMON7\IDE\EXTENSIONS\MICROSOFT\PYTHON\CORE\PythonFiles\testing_tools\run_adapter.py discover unittest --output-file C:\Users\vting\AppData\Local\Temp\tmp4413.tmp -- . test*.py ========== Test discovery finished: 1 Tests found in 2.6 sec ========== System.AggregateException: One or more errors occurred. ---> System.ArgumentNullException: Value cannot be null. Parameter name: element at MS.Internal.Media.VisualTreeUtils.AsNonNullVisual(DependencyObject element, Visual& visual, Visual3D& visual3D) at System.Windows.Media.VisualTreeHelper.GetChildrenCount(DependencyObject reference) at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.FindDescendant[T](DependencyObject parent) at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.TryFindSummaryDockPanel(DockPanel& summaryPanel, TextBlock& titleBox) at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.d 22.MoveNext()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.get_AskCopilotBtn()
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.d19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.<>cDisplayClass18_0.<b0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread()
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.AppendContent(ISummaryGenerator summaryGenerator, String indent, CancellationToken cancellation)
at Microsoft.VisualStudio.TestWindow.Logging.ILoggerExtensions.CallInternalWithLogging(IInternalLogger log, Action action, Boolean shouldThrow)
---> (Inner Exception #0) System.ArgumentNullException: Value cannot be null.
Parameter name: element
at MS.Internal.Media.VisualTreeUtils.AsNonNullVisual(DependencyObject element, Visual& visual, Visual3D& visual3D)
at System.Windows.Media.VisualTreeHelper.GetChildrenCount(DependencyObject reference)
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.FindDescendant[T](DependencyObject parent)
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.TryFindSummaryDockPanel(DockPanel& summaryPanel, TextBlock& titleBox)
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.d 22.MoveNext()<---
Building Test Projects ========== Starting test run ========== cd C:\Users\vting\source\repos\PythonApplication13\PythonApplication13\ set PYTHONPATH=C:\Users\vting\source\repos\PythonApplication13\PythonApplication13;C:\Users\vting\source\repos\PythonApplication13\PythonApplication13\ "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64qbz5n2kfra8p0\python3.9.exe" "C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\PREVIEW\COMMON7\IDE\EXTENSIONS\MICROSOFT\PYTHON\CORE\visualstudio_py_testlauncher.py" -t test_1.Test_test_1.test_A -r 55532 Connected to socket Connection event fired ========== Test run finished: 1 Tests (0 Passed, 1 Failed, 0 Skipped) run in 250 ms ========== System.AggregateException: One or more errors occurred. ---> System.ArgumentNullException: Value cannot be null. Parameter name: element at MS.Internal.Media.VisualTreeUtils.AsNonNullVisual(DependencyObject element, Visual& visual, Visual3D& visual3D) at System.Windows.Media.VisualTreeHelper.GetChildrenCount(DependencyObject reference) at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.FindDescendant[T](DependencyObject parent) at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.TryFindSummaryDockPanel(DockPanel& summaryPanel, TextBlock& titleBox) at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.d 22.MoveNext()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.get_AskCopilotBtn()
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.d19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.<>cDisplayClass18_0.<b0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread()
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.AppendContent(ISummaryGenerator summaryGenerator, String indent, CancellationToken cancellation)
at Microsoft.VisualStudio.TestWindow.Logging.ILoggerExtensions.CallInternalWithLogging(IInternalLogger log, Action action, Boolean shouldThrow)
---> (Inner Exception #0) System.ArgumentNullException: Value cannot be null.
Parameter name: element
at MS.Internal.Media.VisualTreeUtils.AsNonNullVisual(DependencyObject element, Visual& visual, Visual3D& visual3D)
at System.Windows.Media.VisualTreeHelper.GetChildrenCount(DependencyObject reference)
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.FindDescendant[T](DependencyObject parent)
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.TryFindSummaryDockPanel(DockPanel& summaryPanel, TextBlock& titleBox)
at Microsoft.VisualStudio.TestWindow.Copilot.Summary.SummaryExtender.d 22.MoveNext()<---