Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0050f5b

Browse filesBrowse files
authored
fix regression with import packaging for branch coverage (#25070) (#25074)
fixes #25044
1 parent d597e1c commit 0050f5b
Copy full SHA for 0050f5b

File tree

Expand file treeCollapse file tree

2 files changed

+14
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+14
-3
lines changed

‎python_files/unittestadapter/execution.py

Copy file name to clipboardExpand all lines: python_files/unittestadapter/execution.py
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
from types import TracebackType
1313
from typing import Dict, List, Optional, Set, Tuple, Type, Union
1414

15-
from packaging.version import Version
16-
1715
# Adds the scripts directory to the PATH as a workaround for enabling shell for test execution.
1816
path_var_name = "PATH" if "PATH" in os.environ else "Path"
1917
os.environ[path_var_name] = (
@@ -326,6 +324,13 @@ def send_run_data(raw_data, test_run_pipe):
326324
)
327325
import coverage
328326

327+
# insert "python_files/lib/python" into the path so packaging can be imported
328+
python_files_dir = pathlib.Path(__file__).parent.parent
329+
bundled_dir = pathlib.Path(python_files_dir / "lib" / "python")
330+
sys.path.append(os.fspath(bundled_dir))
331+
332+
from packaging.version import Version
333+
329334
coverage_version = Version(coverage.__version__)
330335
# only include branches if coverage version is 7.7.0 or greater (as this was when the api saves)
331336
if coverage_version >= Version("7.7.0"):

‎python_files/vscode_pytest/__init__.py

Copy file name to clipboardExpand all lines: python_files/vscode_pytest/__init__.py
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from typing import TYPE_CHECKING, Any, Dict, Generator, Literal, TypedDict
1414

1515
import pytest
16-
from packaging.version import Version
1716

1817
if TYPE_CHECKING:
1918
from pluggy import Result
@@ -443,6 +442,13 @@ def pytest_sessionfinish(session, exitstatus):
443442
# load the report and build the json result to return
444443
import coverage
445444

445+
# insert "python_files/lib/python" into the path so packaging can be imported
446+
python_files_dir = pathlib.Path(__file__).parent.parent
447+
bundled_dir = pathlib.Path(python_files_dir / "lib" / "python")
448+
sys.path.append(os.fspath(bundled_dir))
449+
450+
from packaging.version import Version
451+
446452
coverage_version = Version(coverage.__version__)
447453
global INCLUDE_BRANCHES
448454
# only include branches if coverage version is 7.7.0 or greater (as this was when the api saves)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.