|
25 | 25 |
|
26 | 26 | test_env = FileDrivenTesting() |
27 | 27 | test_env.test_data_dir = os.path.join(os.path.dirname(__file__), "data") |
| 28 | +setup_test_env = FileDrivenTesting() |
| 29 | +setup_test_env.test_data_dir = os.path.join(os.path.dirname(__file__), "data", "setup") |
28 | 30 |
|
29 | 31 |
|
30 | 32 | @pytest.mark.online |
@@ -212,6 +214,31 @@ def test_cli_with_pinned_requirements_file(): |
212 | 214 | ) |
213 | 215 |
|
214 | 216 |
|
| 217 | +@pytest.mark.online |
| 218 | +def test_cli_with_setup_py_failure(): |
| 219 | + setup_py_file = setup_test_env.get_test_loc("simple-setup.py") |
| 220 | + expected_file = setup_test_env.get_test_loc("simple-setup.py-expected.json", must_exist=False) |
| 221 | + check_setup_py_resolution( |
| 222 | + setup_py=setup_py_file, |
| 223 | + expected_file=expected_file, |
| 224 | + regen=REGEN_TEST_FIXTURES, |
| 225 | + expected_rc=1, |
| 226 | + message=f"Python version 3.8 is not compatible with setup.py {setup_py_file} python_requires >2, <=3", |
| 227 | + ) |
| 228 | + |
| 229 | + |
| 230 | +@pytest.mark.online |
| 231 | +def test_cli_with_setup_py(): |
| 232 | + setup_py_file = setup_test_env.get_test_loc("simple-setup.py") |
| 233 | + expected_file = setup_test_env.get_test_loc("simple-setup.py-expected.json", must_exist=False) |
| 234 | + check_setup_py_resolution( |
| 235 | + setup_py=setup_py_file, |
| 236 | + expected_file=expected_file, |
| 237 | + regen=REGEN_TEST_FIXTURES, |
| 238 | + extra_options=["--python-version", "27"], |
| 239 | + ) |
| 240 | + |
| 241 | + |
215 | 242 | def check_specs_resolution( |
216 | 243 | specifier, |
217 | 244 | expected_file, |
@@ -276,6 +303,30 @@ def check_requirements_resolution( |
276 | 303 | ) |
277 | 304 |
|
278 | 305 |
|
| 306 | +def check_setup_py_resolution( |
| 307 | + setup_py, |
| 308 | + expected_file, |
| 309 | + extra_options=tuple(), |
| 310 | + regen=REGEN_TEST_FIXTURES, |
| 311 | + pdt_output=False, |
| 312 | + expected_rc=0, |
| 313 | + message="", |
| 314 | +): |
| 315 | + result_file = setup_test_env.get_temp_file(file_name="json") |
| 316 | + if pdt_output: |
| 317 | + options = ["--setup-py", setup_py, "--json-pdt", result_file] |
| 318 | + else: |
| 319 | + options = ["--setup-py", setup_py, "--json", result_file] |
| 320 | + options.extend(extra_options) |
| 321 | + result = run_cli(options=options, expected_rc=expected_rc) |
| 322 | + if message: |
| 323 | + assert message in result.output |
| 324 | + if expected_rc == 0: |
| 325 | + check_json_results( |
| 326 | + result_file=result_file, expected_file=expected_file, regen=regen, clean=not pdt_output |
| 327 | + ) |
| 328 | + |
| 329 | + |
279 | 330 | def check_json_results(result_file, expected_file, clean=True, regen=REGEN_TEST_FIXTURES): |
280 | 331 | """ |
281 | 332 | Check the ``result_file`` JSON results against the ``expected_file`` |
|
0 commit comments