Skip to content

Commit 711b19a

Browse files
committed
Added fixture to infer PTB minimum python version
1 parent f7bd55a commit 711b19a

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

test/integration/conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
import subprocess
2+
from pathlib import Path
23

34
import pytest
45

6+
from exasol.toolbox.config import BaseConfig
7+
58

69
@pytest.fixture(scope="session")
710
def poetry_path() -> str:
811
result = subprocess.run(["which", "poetry"], capture_output=True, text=True)
912
poetry_path = result.stdout.strip()
1013
return poetry_path
14+
15+
16+
@pytest.fixture(scope="session")
17+
def ptb_minimum_python_version() -> str:
18+
return BaseConfig(root_path=Path(), project_name="toolbox").minimum_python_version

test/integration/util/dependencies/audit_integration_test.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import json
44
import re
55
import subprocess
6-
import sys
76
from inspect import cleandoc
87
from pathlib import Path
98

@@ -53,20 +52,15 @@ def create(self) -> PoetryProject:
5352
aux_subprocess(self.poetry, "new", self.name, cwd=self.dir.parent)
5453
return self
5554

56-
def use_python_version(self, version: sys.version_info) -> PoetryProject:
55+
def set_minimum_python_version(self, version: str) -> PoetryProject:
5756
content = self.toml.read_text()
58-
python_version = f"{version.major}.{version.minor}"
59-
python_version = "3.10"
6057
changed = re.sub(
6158
r'^requires-python = ".*"$',
62-
f'requires-python = ">={python_version}"',
59+
f'requires-python = ">={version}"',
6360
content,
6461
flags=re.MULTILINE,
6562
)
6663
self.toml.write_text(changed)
67-
# aux_subprocess(
68-
# self.poetry, "env", "use", f"python{python_version}", cwd=self.dir
69-
# )
7064
return self
7165

7266
def add_package(self, spec: str) -> PoetryProject:
@@ -84,11 +78,11 @@ def install(self) -> PoetryProject:
8478

8579

8680
@pytest.fixture
87-
def create_poetry_project(tmp_path, sample_vulnerability, poetry_path):
81+
def create_poetry_project(tmp_path, sample_vulnerability, poetry_path, ptb_minimum_python_version):
8882
project = (
8983
PoetryProject(poetry_path, tmp_path / "vulnerability")
9084
.create()
91-
.use_python_version(sys.version_info)
85+
.set_minimum_python_version(ptb_minimum_python_version)
9286
.add_package(
9387
f"{sample_vulnerability.package_name}==" f"{sample_vulnerability.version}"
9488
)

0 commit comments

Comments
 (0)