Skip to content

Commit a13768f

Browse files
committed
[test/fix] Implemented a fix for VCRHTTPResponse.version_string
kevin1024/vcrpy#888
1 parent 50321a7 commit a13768f

File tree

5 files changed

+28
-121
lines changed

5 files changed

+28
-121
lines changed

.github/workflows/pyatlan-pr.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ jobs:
5959
python -m pip install --no-cache-dir --upgrade pip setuptools
6060
if [ -f requirements.txt ]; then pip install --no-cache-dir -r requirements.txt; fi
6161
if [ -f requirements-dev.txt ]; then pip install --no-cache-dir -r requirements-dev.txt; fi
62-
pip list
6362
6463
- name: QA checks (ruff-format, ruff-lint, mypy)
6564
run: |
@@ -106,7 +105,6 @@ jobs:
106105
python -m pip install --no-cache-dir --upgrade pip setuptools
107106
if [ -f requirements.txt ]; then pip install --no-cache-dir -r requirements.txt; fi
108107
if [ -f requirements-dev.txt ]; then pip install --no-cache-dir -r requirements-dev.txt; fi
109-
pip list
110108
111109
- name: Run integration tests
112110
env: # Test tenant environment variables

pyatlan/test_utils/base_vcr.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@
1313
"pytest-vcr plugin is not installed. Please install pytest-vcr."
1414
)
1515

16-
# # Check if vcrpy is installed and ensure the version is 6.0.x
17-
# try:
18-
# vcr_version = pkg_resources.get_distribution("vcrpy").version
19-
# if not vcr_version.startswith("6.0"):
20-
# raise DependencyNotFoundError(
21-
# f"vcrpy version 6.0.x is required, but found {vcr_version}. Please install the correct version."
22-
# )
23-
# except pkg_resources.DistributionNotFound:
24-
# raise DependencyNotFoundError(
25-
# "vcrpy version 6.0.x is not installed. Please install vcrpy version 6.0.x."
26-
# )
16+
# Check if vcrpy is installed and ensure the version is 6.0.x
17+
try:
18+
vcr_version = pkg_resources.get_distribution("vcrpy").version
19+
if not vcr_version.startswith("6.0"):
20+
raise DependencyNotFoundError(
21+
f"vcrpy version 6.0.x is required, but found {vcr_version}. Please install the correct version."
22+
)
23+
except pkg_resources.DistributionNotFound:
24+
raise DependencyNotFoundError(
25+
"vcrpy version 6.0.x is not installed. Please install vcrpy version 6.0.x."
26+
)
2727

2828
import json
2929
import os

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pytest~=8.3.4
88
pytest-vcr~=1.0.2
99
# [PINNED] to v6.x since vcrpy>=7.0 requires urllib3>=2.0
1010
# which breaks compatibility with Python 3.8
11-
# vcrpy~=6.0.2
11+
vcrpy~=6.0.2
1212
pytest-order~=1.3.0
1313
pytest-timer[termcolor]~=1.0.0
1414
pytest-sugar~=1.0.0

test_vcr.py

Lines changed: 0 additions & 107 deletions
This file was deleted.

tests/unit/conftest.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,19 @@ def mock_custom_metadata_cache():
3131
def mock_tag_cache():
3232
with patch("pyatlan.cache.atlan_tag_cache.AtlanTagCache") as cache:
3333
yield cache
34+
35+
36+
@pytest.fixture(autouse=True)
37+
def patch_vcr_http_response_version_string():
38+
"""
39+
Patch the VCRHTTPResponse class to add a version_string attribute if it doesn't exist.
40+
41+
This patch is necessary to avoid bumping vcrpy to 7.0.0,
42+
which drops support for Python 3.8.
43+
"""
44+
from vcr.stubs import VCRHTTPResponse # type: ignore[import-untyped]
45+
46+
if not hasattr(VCRHTTPResponse, "version_string"):
47+
VCRHTTPResponse.version_string = None
48+
49+
yield

0 commit comments

Comments
 (0)