microsoft / PTVS

Python Tools for Visual Studio
https://aka.ms/PTVS
Apache License 2.0
2.52k stars 673 forks source link

The error "System.AggregateException: One or more errors occurred." occurred during testing. #7855

Closed ttSpace closed 3 months ago

ttSpace commented 3 months ago

Describe the bug

image

Python from Microsoft Store.

Steps to Reproduce

  1. Create a Python Application project.
  2. Right-click project, select Add > New Item …, then select "Python Unit Test" followed by "Add".
  3. 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()<---



</p>
</details>
StellaHuang95 commented 3 months ago

This is an upstream issue. See https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1993408