-
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add helper to get the Python listing (#877)
* feat: add helper to get the Python listing Signed-off-by: Henry Schreiner <[email protected]> * Update nox/project.py * refactor: python_list -> python_versions Signed-off-by: Henry Schreiner <[email protected]> --------- Signed-off-by: Henry Schreiner <[email protected]>
- Loading branch information
Showing
4 changed files
with
136 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import pytest | ||
|
||
from nox.project import python_versions | ||
|
||
|
||
def test_classifiers(): | ||
pyproject = { | ||
"project": { | ||
"classifiers": [ | ||
"Programming Language :: Python :: 3.7", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.12", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3 :: Only", | ||
"Topic :: Software Development :: Testing", | ||
], | ||
"requires-python": ">=3.10", | ||
} | ||
} | ||
|
||
assert python_versions(pyproject) == ["3.7", "3.9", "3.12"] | ||
|
||
|
||
def test_no_classifiers(): | ||
pyproject = {"project": {"requires-python": ">=3.9"}} | ||
with pytest.raises(ValueError, match="No Python version classifiers"): | ||
python_versions(pyproject) | ||
|
||
|
||
def test_no_requires_python(): | ||
pyproject = {"project": {"classifiers": ["Programming Language :: Python :: 3.12"]}} | ||
with pytest.raises(ValueError, match='No "project.requires-python" value set'): | ||
python_versions(pyproject, max_version="3.13") | ||
|
||
|
||
def test_python_range(): | ||
pyproject = { | ||
"project": { | ||
"classifiers": [ | ||
"Programming Language :: Python :: 3.7", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.12", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3 :: Only", | ||
"Topic :: Software Development :: Testing", | ||
], | ||
"requires-python": ">=3.10", | ||
} | ||
} | ||
|
||
assert python_versions(pyproject, max_version="3.12") == ["3.10", "3.11", "3.12"] | ||
assert python_versions(pyproject, max_version="3.11") == ["3.10", "3.11"] | ||
|
||
|
||
def test_python_range_gt(): | ||
pyproject = {"project": {"requires-python": ">3.2.1,<3.3"}} | ||
|
||
assert python_versions(pyproject, max_version="3.4") == ["3.2", "3.3", "3.4"] | ||
|
||
|
||
def test_python_range_no_min(): | ||
pyproject = {"project": {"requires-python": "==3.3.1"}} | ||
|
||
with pytest.raises(ValueError, match="No minimum version found"): | ||
python_versions(pyproject, max_version="3.5") |