Skip to content

Commit c6c6e52

Browse files
committed
Fix version number patter test
1 parent 0c3d161 commit c6c6e52

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/venv-cli/venv.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ _green="\033[32m"
55
_yellow="\033[01;33m"
66
_red="\033[31m"
77

8+
# Version number has to follow pattern "^v\d+\.\d+\.\d+.*$"
89
_version="v1.0.1"
910

1011
venv::_version() {

tests/test_venv_version.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import re
2-
from pathlib import Path
32

43
import pytest
54

65
from tests.helpers import run_command
76

7+
_version_pattern = re.compile(r"^venv-cli v\d+\.\d+\.\d+.*$")
8+
89

910
@pytest.mark.parametrize("arg", ["-V", "--version"])
10-
def test_venv_help(arg: str, tmp_path: Path, capfd: pytest.CaptureFixture):
11-
"""Checks that we can show the version number"""
12-
run_command(f"venv {arg}", cwd=tmp_path)
11+
def test_venv_version(arg: str, capfd: pytest.CaptureFixture):
12+
"""Checks that we can show the version number, and that the version number
13+
complies with the required pattern"""
14+
run_command(f"venv {arg}")
1315

14-
captured = capfd.readouterr()
15-
assert re.search(r"venv-cli\s\d+?\.\d+?\.\d+?", captured.out)
16+
output = capfd.readouterr().out
17+
assert re.match(_version_pattern, output.strip())

0 commit comments

Comments
 (0)