Skip to content

Commit a168566

Browse files
authored
tests: use most recent repo-review in testing (#414)
Signed-off-by: Henry Schreiner <[email protected]>
1 parent e0440e0 commit a168566

File tree

4 files changed

+38
-36
lines changed

4 files changed

+38
-36
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ repos:
5252
- click
5353
- markdown-it-py
5454
- pytest
55-
- repo-review
55+
- repo-review>=0.10.6
5656
- rich
5757
- tomli
5858
- types-PyYAML

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ dynamic = ["version", "readme"]
3232
dependencies = [
3333
"pyyaml",
3434
"repo-review",
35+
"tomli; python_version<'3.11'",
3536
]
3637

3738
[project.optional-dependencies]
@@ -40,7 +41,7 @@ cli = [
4041
]
4142
test = [
4243
"pytest >=7",
43-
"repo-review >=0.10.5",
44+
"repo-review >=0.10.6",
4445
]
4546
dev = [
4647
"pytest >=7",

tests/test_pyproject.py

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,94 @@
1-
from sp_repo_review._compat import tomllib
2-
from sp_repo_review.checks import pyproject
1+
from repo_review.testing import compute_check, toml_loads
32

43

54
def test_PP002_okay():
6-
toml = tomllib.loads("""
5+
toml = toml_loads("""
76
[build-system]
87
requires = ["setuptools"]
98
build-backend = "setuptools.build_meta"
109
""")
11-
assert pyproject.PP002.check(toml)
10+
assert compute_check("PP002", pyproject=toml).result
1211

1312

1413
def test_PP002_not_list():
15-
toml = tomllib.loads("""
14+
toml = toml_loads("""
1615
[build-system]
1716
requires = "setuptools"
1817
build-backend = "setuptools.build_meta"
1918
""")
20-
assert not pyproject.PP002.check(toml)
19+
assert not compute_check("PP002", pyproject=toml).result
2120

2221

2322
def test_PP002_missing():
24-
toml = tomllib.loads("""
23+
toml = toml_loads("""
2524
[project]
2625
name = "hi"
2726
version = "1.0.0"
2827
""")
29-
assert not pyproject.PP002.check(toml)
28+
assert not compute_check("PP002", pyproject=toml).result
3029

3130

3231
def test_PP003_no_wheel():
33-
toml = tomllib.loads("""
32+
toml = toml_loads("""
3433
[build-system]
3534
requires = ["setuptools"]
3635
build-backend = "setuptools.build_meta"
3736
""")
38-
assert pyproject.PP003.check(toml)
37+
assert compute_check("PP003", pyproject=toml).result
3938

4039

4140
def test_PP003_has_wheel():
42-
toml = tomllib.loads("""
41+
toml = toml_loads("""
4342
[build-system]
4443
requires = ["setuptools", "wheel"]
4544
build-backend = "setuptools.build_meta"
4645
""")
47-
assert not pyproject.PP003.check(toml)
46+
assert not compute_check("PP003", pyproject=toml).result
4847

4948

5049
def test_PP302_okay_intstr():
51-
toml = tomllib.loads("""
50+
toml = toml_loads("""
5251
[tool.pytest.ini_options]
5352
minversion = "7"
5453
""")
55-
assert pyproject.PP302.check(toml)
54+
assert compute_check("PP302", pyproject=toml).result
5655

5756

5857
def test_PP302_okay_verstr():
59-
toml = tomllib.loads("""
58+
toml = toml_loads("""
6059
[tool.pytest.ini_options]
6160
minversion = "7.0.2"
6261
""")
63-
assert pyproject.PP302.check(toml)
62+
assert compute_check("PP302", pyproject=toml).result
6463

6564

6665
def test_PP302_okay_rawint():
67-
toml = tomllib.loads("""
66+
toml = toml_loads("""
6867
[tool.pytest.ini_options]
6968
minversion = 7
7069
""")
71-
assert pyproject.PP302.check(toml)
70+
assert compute_check("PP302", pyproject=toml).result
7271

7372

7473
def test_PP302_okay_rawfloat():
75-
toml = tomllib.loads("""
74+
toml = toml_loads("""
7675
[tool.pytest.ini_options]
7776
minversion = 7.0
7877
""")
79-
assert pyproject.PP302.check(toml)
78+
assert compute_check("PP302", pyproject=toml).result
8079

8180

8281
def test_PP302_missing():
83-
toml = tomllib.loads("""
82+
toml = toml_loads("""
8483
[tool.pytest]
8584
ini_options = {}
8685
""")
87-
assert not pyproject.PP302.check(toml)
86+
assert not compute_check("PP302", pyproject=toml).result
8887

8988

9089
def test_PP302_too_low():
91-
toml = tomllib.loads("""
90+
toml = toml_loads("""
9291
[tool.pytest.ini_options]
9392
minversion = "5"
9493
""")
95-
assert not pyproject.PP302.check(toml)
94+
assert not compute_check("PP302", pyproject=toml).result

tests/test_ruff.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,35 @@
1-
from sp_repo_review._compat import tomllib
2-
from sp_repo_review.checks import ruff
1+
from repo_review.testing import compute_check, toml_loads
32

43

54
def test_rf003_with_rp():
6-
toml = tomllib.loads("""
5+
toml = toml_loads("""
76
project.requires-python = ">=3.12"
87
tool.ruff.anything = "1"
98
""")
10-
assert ruff.RF002.check(toml, toml["tool"]["ruff"])
9+
assert compute_check("RF002", pyproject=toml, ruff=toml["tool"]["ruff"]).result
1110

1211

1312
def test_rf003_no_rp():
14-
toml = tomllib.loads("""
13+
toml = toml_loads("""
1514
project.name = "hi"
1615
tool.ruff.target-version = "3.12"
1716
""")
18-
assert ruff.RF002.check(toml, toml["tool"]["ruff"])
17+
assert compute_check("RF002", pyproject=toml, ruff=toml["tool"]["ruff"]).result
1918

2019

2120
def test_rf003_both():
22-
toml = tomllib.loads("""
21+
toml = toml_loads("""
2322
project.requires-python = ">=3.12"
2423
tool.ruff.target-version = "3.12"
2524
""")
26-
assert isinstance(ruff.RF002.check(toml, toml["tool"]["ruff"]), str)
25+
check_result = compute_check("RF002", pyproject=toml, ruff=toml["tool"]["ruff"])
26+
assert check_result.result is False
2727

2828

2929
def test_rf003_split_ok():
30-
toml = tomllib.loads("""
30+
toml = toml_loads("""
3131
project.requires-python = ">=3.12"
3232
""")
33-
assert ruff.RF002.check(toml, {"target-version": "3.12"})
33+
assert compute_check(
34+
"RF002", pyproject=toml, ruff={"target-version": "3.12"}
35+
).result

0 commit comments

Comments
 (0)