Skip to content

Commit 73d13ad

Browse files
committed
fix(tests): make test_version 3.10-compatible
tomllib is stdlib only from Python 3.11+; using it in test_scaffold.py broke the unit-tests matrix on 3.10 (release-rc workflow run 25296518321). Switch to a regex match so the test runs on every supported Python without pulling in tomli as a dev dep.
1 parent c458e5c commit 73d13ad

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎tests/unit/test_scaffold.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
from __future__ import annotations
44

5+
import re
56
from pathlib import Path
67
from typing import Any
78

89
import pytest
9-
import tomllib
1010

1111
from pinecone import __version__
1212
from pinecone._internal.config import PineconeConfig
@@ -30,8 +30,11 @@
3030
def test_version() -> None:
3131
# Catch the "pyproject.toml and pinecone/__init__.py drifted" bug, but stay
3232
# version-agnostic so a release bump doesn't have to edit this test.
33-
pyproject = tomllib.loads(Path(__file__).parents[2].joinpath("pyproject.toml").read_text())
34-
assert __version__ == pyproject["project"]["version"]
33+
# Use regex over tomllib so this test runs on Python 3.10 (tomllib is 3.11+).
34+
text = Path(__file__).parents[2].joinpath("pyproject.toml").read_text()
35+
match = re.search(r'^version\s*=\s*"([^"]+)"', text, re.MULTILINE)
36+
assert match is not None, "could not find version line in pyproject.toml"
37+
assert __version__ == match.group(1)
3538

3639

3740
def test_config_defaults() -> None:

0 commit comments

Comments
 (0)