|
| 1 | +from sp_repo_review._compat import tomllib |
| 2 | +from sp_repo_review.checks import pyproject |
| 3 | + |
| 4 | + |
| 5 | +def test_PP002_okay(): |
| 6 | + toml = tomllib.loads(""" |
| 7 | + [build-system] |
| 8 | + requires = ["setuptools"] |
| 9 | + build-backend = "setuptools.build_meta" |
| 10 | + """) |
| 11 | + assert pyproject.PP002.check(toml) |
| 12 | + |
| 13 | + |
| 14 | +def test_PP002_not_list(): |
| 15 | + toml = tomllib.loads(""" |
| 16 | + [build-system] |
| 17 | + requires = "setuptools" |
| 18 | + build-backend = "setuptools.build_meta" |
| 19 | + """) |
| 20 | + assert not pyproject.PP002.check(toml) |
| 21 | + |
| 22 | + |
| 23 | +def test_PP002_missing(): |
| 24 | + toml = tomllib.loads(""" |
| 25 | + [project] |
| 26 | + name = "hi" |
| 27 | + version = "1.0.0" |
| 28 | + """) |
| 29 | + assert not pyproject.PP002.check(toml) |
| 30 | + |
| 31 | + |
| 32 | +def test_PP003_no_wheel(): |
| 33 | + toml = tomllib.loads(""" |
| 34 | + [build-system] |
| 35 | + requires = ["setuptools"] |
| 36 | + build-backend = "setuptools.build_meta" |
| 37 | + """) |
| 38 | + assert pyproject.PP003.check(toml) |
| 39 | + |
| 40 | + |
| 41 | +def test_PP003_has_wheel(): |
| 42 | + toml = tomllib.loads(""" |
| 43 | + [build-system] |
| 44 | + requires = ["setuptools", "wheel"] |
| 45 | + build-backend = "setuptools.build_meta" |
| 46 | + """) |
| 47 | + assert not pyproject.PP003.check(toml) |
| 48 | + |
| 49 | + |
| 50 | +def test_PP302_okay_intstr(): |
| 51 | + toml = tomllib.loads(""" |
| 52 | + [tool.pytest.ini_options] |
| 53 | + minversion = "7" |
| 54 | + """) |
| 55 | + assert pyproject.PP302.check(toml) |
| 56 | + |
| 57 | + |
| 58 | +def test_PP302_okay_verstr(): |
| 59 | + toml = tomllib.loads(""" |
| 60 | + [tool.pytest.ini_options] |
| 61 | + minversion = "7.0.2" |
| 62 | + """) |
| 63 | + assert pyproject.PP302.check(toml) |
| 64 | + |
| 65 | + |
| 66 | +def test_PP302_okay_rawint(): |
| 67 | + toml = tomllib.loads(""" |
| 68 | + [tool.pytest.ini_options] |
| 69 | + minversion = 7 |
| 70 | + """) |
| 71 | + assert pyproject.PP302.check(toml) |
| 72 | + |
| 73 | + |
| 74 | +def test_PP302_okay_rawfloat(): |
| 75 | + toml = tomllib.loads(""" |
| 76 | + [tool.pytest.ini_options] |
| 77 | + minversion = 7.0 |
| 78 | + """) |
| 79 | + assert pyproject.PP302.check(toml) |
| 80 | + |
| 81 | + |
| 82 | +def test_PP302_missing(): |
| 83 | + toml = tomllib.loads(""" |
| 84 | + [tool.pytest] |
| 85 | + ini_options = {} |
| 86 | + """) |
| 87 | + assert not pyproject.PP302.check(toml) |
| 88 | + |
| 89 | + |
| 90 | +def test_PP302_too_low(): |
| 91 | + toml = tomllib.loads(""" |
| 92 | + [tool.pytest.ini_options] |
| 93 | + minversion = "5" |
| 94 | + """) |
| 95 | + assert not pyproject.PP302.check(toml) |
0 commit comments