Skip to content

Commit 2963ae4

Browse files
committed
Added first test
1 parent 192541d commit 2963ae4

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

exasol/toolbox/nox/_artifacts.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,14 @@ def _combine_coverage(session: Session, dir: Path, pattern: str):
156156
if args := [f for f in dir.glob(pattern) if f.exists()]:
157157
session.run("coverage", "combine", "--keep", *args)
158158
else:
159-
print(f"Could not find any file {dir}/{pattern}")
159+
print(f"Could not find any file {dir}/{pattern}", file=sys.stderr)
160160

161161

162162
def _copy_artifacts(dir: Path, *files: str):
163163
for file in files:
164164
path = dir / file
165165
if path.exists():
166-
print(f"Copying file {path}")
166+
print(f"Copying file {path}", file=sys.stderr)
167167
shutil.copy(path, ".")
168168
else:
169-
print(f"File not found {path}")
169+
print(f"File not found {path}", file=sys.stderr)

test/unit/artifacts_test.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import pytest
2+
import re
3+
from inspect import cleandoc
4+
from unittest.mock import Mock, patch
5+
from exasol.toolbox.nox._artifacts import copy_artifacts
6+
7+
8+
9+
@pytest.fixture
10+
def python_version():
11+
return "9.9"
12+
13+
14+
@pytest.fixture
15+
def project_config(python_version):
16+
with patch("exasol.toolbox.nox._artifacts.PROJECT_CONFIG") as config:
17+
config.python_versions = [python_version]
18+
yield config
19+
20+
21+
def test_no_coverage(project_config, tmp_path, capsys):
22+
session = Mock(posargs=[str(tmp_path)])
23+
copy_artifacts(session)
24+
captured = capsys.readouterr()
25+
re.match(
26+
cleandoc(
27+
f"""
28+
Could not find any file .*/coverage-python9.9\\*/.coverage
29+
File not found .*/lint-python9.9/.lint.txt
30+
File not found .*/lint-python9.9/.lint.json
31+
File not found .*/security-python9.9/.security.json
32+
"""
33+
),
34+
captured.err,
35+
)
36+
with capsys.disabled():
37+
print(captured.err)

0 commit comments

Comments
 (0)