MCPcopy
hub / github.com/tox-dev/tox / test_req_over_http

Function test_req_over_http

tests/tox_env/python/pip/req/test_file.py:498–510  ·  view source on GitHub ↗
(tmp_path: Path, flag: str, mocker: MockerFixture)

Source from the content-addressed store, hash-verified

496
497@pytest.mark.parametrize("flag", ["-r", "--requirement", "-c", "--constraint"])
498def test_req_over_http(tmp_path: Path, flag: str, mocker: MockerFixture) -> None:
499 is_constraint = flag in {"-c", "--constraint"}
500 url_open = mocker.patch("tox.tox_env.python.pip.req.file.urlopen", autospec=True)
501 url_open.return_value.__enter__.return_value = BytesIO(b"-i i\na")
502 requirements_txt = tmp_path / "req.txt"
503 requirements_txt.write_text(f"{flag} https://zopefoundation.github.io/Zope/releases/4.5.5/requirements-full.txt")
504 req_file = RequirementsFile(requirements_txt, constraint=is_constraint)
505 assert str(req_file) == f"-{'c' if is_constraint else 'r'} {requirements_txt}"
506 assert vars(req_file.options) == {"index_url": ["i"]}
507 found = [str(i) for i in req_file.requirements]
508 assert found == [f"{'-c ' if is_constraint else ''}a"]
509 # urlopen must be called with a timeout to avoid hanging on slow / unresponsive mirrors
510 assert url_open.call_args.kwargs.get("timeout") is not None
511
512
513def test_req_over_http_has_req(tmp_path: Path, mocker: MockerFixture) -> None:

Callers

nothing calls this directly

Calls 2

RequirementsFileClass · 0.90
getMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…