Skip to content

Commit

Permalink
✅ Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatXliner committed May 25, 2024
1 parent 0a42525 commit 93c554d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
- "3.11"
- "3.12"
- |
3.6
3.8
3.9
3.10
Expand Down
4 changes: 4 additions & 0 deletions tests/examples/no_dep_cacher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# /// script
# requires-python = "<4.0"
# ///
print("Success")
5 changes: 5 additions & 0 deletions tests/examples/pyver_echo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# /// script
# requires-python = "<4.0"
# ///
import sys
print('.'.join(map(str,sys.version_info[:2])))
21 changes: 21 additions & 0 deletions tests/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,24 @@ def test_force_short_impossible_python(self):
)
assert result.exit_code == 1
assert "not found" in result.stderr


@pytest.mark.usefixtures("empty_cache")
def test_python_resolver(capfd):
python_version = "3.6" # an egregiously low Python version
result = runner.invoke(
cli,
[
"--force-version",
python_version,
"tests/examples/no_dep_cacher.py",
],
)
assert result.exit_code == 0
out, _ = capfd.readouterr()
assert out.replace("\r", "") == "Success\n"
print(list(CACHE_DIR.glob("*")))
result = runner.invoke(cli, ["tests/examples/pyver_echo.py"])
assert result.exit_code == 0
out, _ = capfd.readouterr()
assert out.replace("\r", "") == python_version + "\n"

0 comments on commit 93c554d

Please sign in to comment.