Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rr): pytest takes ints and floats #398

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/sp_repo_review/checks/pyproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ def check(pyproject: dict[str, Any]) -> bool:
```
"""
options = pyproject["tool"]["pytest"]["ini_options"]
return "minversion" in options and int(options["minversion"].split(".")[0]) >= 6
return (
"minversion" in options
and int(str(options["minversion"]).split(".")[0]) >= 6
)


class PP303(PyProject):
Expand Down
95 changes: 95 additions & 0 deletions tests/test_checks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
from sp_repo_review._compat import tomllib
from sp_repo_review.checks import pyproject


def test_PP002_okay():
toml = tomllib.loads("""
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
""")
assert pyproject.PP002.check(toml)


def test_PP002_not_list():
toml = tomllib.loads("""
[build-system]
requires = "setuptools"
build-backend = "setuptools.build_meta"
""")
assert not pyproject.PP002.check(toml)


def test_PP002_missing():
toml = tomllib.loads("""
[project]
name = "hi"
version = "1.0.0"
""")
assert not pyproject.PP002.check(toml)


def test_PP003_no_wheel():
toml = tomllib.loads("""
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
""")
assert pyproject.PP003.check(toml)


def test_PP003_has_wheel():
toml = tomllib.loads("""
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
""")
assert not pyproject.PP003.check(toml)


def test_PP302_okay_intstr():
toml = tomllib.loads("""
[tool.pytest.ini_options]
minversion = "7"
""")
assert pyproject.PP302.check(toml)


def test_PP302_okay_verstr():
toml = tomllib.loads("""
[tool.pytest.ini_options]
minversion = "7.0.2"
""")
assert pyproject.PP302.check(toml)


def test_PP302_okay_rawint():
toml = tomllib.loads("""
[tool.pytest.ini_options]
minversion = 7
""")
assert pyproject.PP302.check(toml)


def test_PP302_okay_rawfloat():
toml = tomllib.loads("""
[tool.pytest.ini_options]
minversion = 7.0
""")
assert pyproject.PP302.check(toml)


def test_PP302_missing():
toml = tomllib.loads("""
[tool.pytest]
ini_options = {}
""")
assert not pyproject.PP302.check(toml)


def test_PP302_too_low():
toml = tomllib.loads("""
[tool.pytest.ini_options]
minversion = "5"
""")
assert not pyproject.PP302.check(toml)