File: test_cli.py

package info (click to toggle)
findpython 0.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 216 kB
  • sloc: python: 1,428; makefile: 48
file content (38 lines) | stat: -rw-r--r-- 1,246 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from findpython.__main__ import cli


def test_cli_find_pythons(mocked_python, capsys):
    retcode = cli(["--all"])
    assert retcode == 0
    out, _ = capsys.readouterr()
    lines = out.strip().splitlines()
    for version, line in zip(("3.9", "3.8", "3.7"), lines):
        assert line.lstrip().startswith(f"cpython@{version}.0")


def test_cli_find_python_by_version(mocked_python, capsys, tmp_path):
    retcode = cli(["3.8"])
    assert retcode == 0
    out, _ = capsys.readouterr()
    line = out.strip()
    assert line.startswith("cpython@3.8.0")
    assert line.endswith(str(tmp_path / "python3.8"))


def test_cli_find_python_freethreaded(mocked_python, capsys, tmp_path):
    mocked_python.add_python(tmp_path / "python3.13", "3.13.0")
    mocked_python.add_python(tmp_path / "python3.13t", "3.13.0", freethreaded=True)

    retcode = cli(["--all", "3.13"])
    assert retcode == 0
    out, _ = capsys.readouterr()
    line = out.strip()
    assert "\n" not in line
    assert line.lstrip().split(":")[0] == "cpython@3.13.0"

    retcode = cli(["--all", "3.13t"])
    assert retcode == 0
    out, _ = capsys.readouterr()
    line = out.strip()
    assert "\n" not in line
    assert line.lstrip().split(":")[0] == "cpython@3.13.0t"