Skip to content

Commit 62ede2b

Browse files
committed
Fix cwd which differs between the tests & real running
1 parent 9f7c2e9 commit 62ede2b

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

exasol/toolbox/nox/_artifacts.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
import sys
88
from collections.abc import Iterable
99
from pathlib import Path
10-
from typing import Optional
10+
from typing import (
11+
Optional,
12+
Union,
13+
)
1114

1215
import nox
1316
from nox import Session
@@ -184,7 +187,9 @@ def _copy_artifacts(source: Path, dest: Path, files: Iterable[str]):
184187
print(f"File not found {path}", file=sys.stderr)
185188

186189

187-
def _prepare_coverage_xml(session: Session, source: Path) -> None:
190+
def _prepare_coverage_xml(
191+
session: Session, source: Path, cwd: Union[Path | None] = None
192+
) -> None:
188193
"""
189194
Prepare the coverage XML for input into Sonar
190195
@@ -208,7 +213,7 @@ def _prepare_coverage_xml(session: Session, source: Path) -> None:
208213
f"{source}/*",
209214
"--fail-under=0",
210215
]
211-
output = subprocess.run(command, capture_output=True, text=True, cwd=source)
216+
output = subprocess.run(command, capture_output=True, text=True, cwd=cwd) # nosec
212217
if output.returncode != 0:
213218
if output.stdout.strip() == "No data to report.":
214219
# Assuming that previous steps passed in the CI, this indicates — as

test/unit/nox/_artifacts_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ def test_no_coverage_file_silently_passes(monkeypatch, tmp_path, nox_session):
361361
coverage_db = tmp_path / COVERAGE_DB
362362
monkeypatch.setattr(_artifacts, "COVERAGE_XML", coverage_xml)
363363

364-
_prepare_coverage_xml(nox_session, tmp_path)
364+
_prepare_coverage_xml(nox_session, tmp_path, cwd=tmp_path)
365365

366366
assert not Path(coverage_db).exists()
367367
assert not Path(coverage_xml).exists()
@@ -378,7 +378,7 @@ def test_that_bad_coverage_file_still_raises_error(
378378
with pytest.raises(
379379
_SessionQuit, match="doesn't seem to be a coverage data file"
380380
):
381-
_prepare_coverage_xml(nox_session, tmp_path)
381+
_prepare_coverage_xml(nox_session, tmp_path, cwd=tmp_path)
382382

383383
assert coverage_db.exists()
384384
assert not coverage_xml.exists()

0 commit comments

Comments
 (0)