|
| 1 | +import configparser |
1 | 2 | import inspect |
2 | | -from pathlib import Path |
3 | 3 |
|
4 | 4 | from repo_review.testing import compute_check, toml_loads |
5 | 5 |
|
@@ -49,68 +49,88 @@ def test_PP003_has_wheel(): |
49 | 49 | assert not compute_check("PP003", pyproject=toml).result |
50 | 50 |
|
51 | 51 |
|
52 | | -def test_PP004_no_cap_pyproject(tmp_path: Path): |
| 52 | +def test_PP004_no_cap_pyproject(): |
53 | 53 | toml = toml_loads(""" |
54 | 54 | [project] |
55 | 55 | requires-python = ">=3.10" |
56 | 56 | """) |
57 | 57 |
|
58 | | - assert compute_check("PP004", pyproject=toml, package=tmp_path).result |
| 58 | + assert compute_check("PP004", pyproject=toml, setupcfg=None).result |
59 | 59 |
|
60 | 60 |
|
61 | | -def test_PP004_cap_pyproject(tmp_path: Path): |
| 61 | +def test_PP004_cap_pyproject(): |
62 | 62 | toml = toml_loads(""" |
63 | 63 | [project] |
64 | 64 | requires-python = ">=3.10, <4" |
65 | 65 | """) |
66 | 66 |
|
67 | | - assert compute_check("PP004", pyproject=toml, package=tmp_path).result is False |
| 67 | + assert compute_check("PP004", pyproject=toml, setupcfg=None).result is False |
68 | 68 |
|
69 | 69 |
|
70 | | -def test_PP004_cap_tilde_pyproject(tmp_path: Path): |
| 70 | +def test_PP004_cap_tilde_pyproject(): |
71 | 71 | toml = toml_loads(""" |
72 | 72 | [project] |
73 | 73 | requires-python = "~=3.10" |
74 | 74 | """) |
75 | 75 |
|
76 | | - assert compute_check("PP004", pyproject=toml, package=tmp_path).result is False |
| 76 | + assert compute_check("PP004", pyproject=toml, setupcfg=None).result is False |
77 | 77 |
|
78 | 78 |
|
79 | | -def test_PP004_cap_caret_pyproject(tmp_path: Path): |
| 79 | +def test_PP004_cap_caret_pyproject(): |
80 | 80 | toml = toml_loads(""" |
81 | 81 | [tool.poetry.dependencies] |
82 | 82 | python = "^3.10" |
83 | 83 | """) |
84 | 84 |
|
85 | | - assert compute_check("PP004", pyproject=toml, package=tmp_path).result is False |
| 85 | + assert compute_check("PP004", pyproject=toml, setupcfg=None).result is False |
86 | 86 |
|
87 | 87 |
|
88 | | -def test_PP004_setup_cfg_no_cap(tmp_path: Path): |
89 | | - (tmp_path / "setup.cfg").write_text( |
90 | | - inspect.cleandoc(""" |
91 | | - [options] |
92 | | - python_requires = >=3.10 |
93 | | - """), |
94 | | - encoding="utf-8", |
95 | | - ) |
| 88 | +def test_PP004_setup_cfg_no_cap(): |
| 89 | + contents = inspect.cleandoc(""" |
| 90 | + [options] |
| 91 | + python_requires = >=3.10 |
| 92 | + """) |
| 93 | + config = configparser.ConfigParser() |
| 94 | + config.read_string(contents) |
| 95 | + |
| 96 | + assert compute_check("PP004", pyproject={}, setupcfg=config).result |
| 97 | + |
| 98 | + |
| 99 | +def test_PP004_setup_cfg_cap(): |
| 100 | + contents = inspect.cleandoc(""" |
| 101 | + [options] |
| 102 | + python_requires = >=3.10,<4 |
| 103 | + """) |
| 104 | + config = configparser.ConfigParser() |
| 105 | + config.read_string(contents) |
96 | 106 |
|
97 | | - assert compute_check("PP004", pyproject={}, package=tmp_path).result |
| 107 | + assert compute_check("PP004", pyproject={}, setupcfg=config).result is False |
98 | 108 |
|
99 | 109 |
|
100 | | -def test_PP004_setup_cfg_cap(tmp_path: Path): |
101 | | - (tmp_path / "setup.cfg").write_text( |
102 | | - inspect.cleandoc(""" |
103 | | - [options] |
104 | | - python_requires = >=3.10,<4 |
105 | | - """), |
106 | | - encoding="utf-8", |
107 | | - ) |
| 110 | +def test_PP004_setup_cfg_no_section(): |
| 111 | + contents = inspect.cleandoc(""" |
| 112 | + [other] |
| 113 | + python_requires = >=3.10 |
| 114 | + """) |
| 115 | + config = configparser.ConfigParser() |
| 116 | + config.read_string(contents) |
| 117 | + |
| 118 | + assert not compute_check("PP004", pyproject={}, setupcfg=config).result |
| 119 | + |
| 120 | + |
| 121 | +def test_PP004_setup_cfg_no_value(): |
| 122 | + contents = inspect.cleandoc(""" |
| 123 | + [options] |
| 124 | + other = >=3.10 |
| 125 | + """) |
| 126 | + config = configparser.ConfigParser() |
| 127 | + config.read_string(contents) |
108 | 128 |
|
109 | | - assert compute_check("PP004", pyproject={}, package=tmp_path).result is False |
| 129 | + assert not compute_check("PP004", pyproject={}, setupcfg=config).result |
110 | 130 |
|
111 | 131 |
|
112 | | -def test_PP004_not_present(tmp_path: Path): |
113 | | - assert compute_check("PP004", pyproject={}, package=tmp_path).result is None |
| 132 | +def test_PP004_not_present(): |
| 133 | + assert compute_check("PP004", pyproject={}, setupcfg=None).result is None |
114 | 134 |
|
115 | 135 |
|
116 | 136 | def test_PP005_no_license(): |
|
0 commit comments