summaryrefslogtreecommitdiff
path: root/tests/tox_env/python
diff options
context:
space:
mode:
authorBernát Gábor <bgabor8@bloomberg.net>2021-01-14 09:41:36 +0000
committerGitHub <noreply@github.com>2021-01-14 09:41:36 +0000
commitd451b7eaed9ea9301ee2c34f98e33faafa654b90 (patch)
treee6b5fc81b40fc734d1aae878bbac66f9f895ae4e /tests/tox_env/python
parentbad3dc570438385ccd84648a6050a89cb5ced0fa (diff)
downloadtox-git-d451b7eaed9ea9301ee2c34f98e33faafa654b90.tar.gz
Support legacy way of specifying constraint files (and expand constraint files too) (#1823)
Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>
Diffstat (limited to 'tests/tox_env/python')
-rw-r--r--tests/tox_env/python/test_req_file.py33
1 files changed, 28 insertions, 5 deletions
diff --git a/tests/tox_env/python/test_req_file.py b/tests/tox_env/python/test_req_file.py
index 40dba1f6..970c47cb 100644
--- a/tests/tox_env/python/test_req_file.py
+++ b/tests/tox_env/python/test_req_file.py
@@ -29,8 +29,6 @@ from tox.tox_env.python.req_file import RequirementsFile
("--extra-index-url a", "--extra-index-url a"),
("-e a", "-e a"),
("--editable a", "--editable a"),
- ("-c a", "-c a"),
- ("--constraint a", "--constraint a"),
("-f a", "-f a"),
("--find-links a", "--find-links a"),
("--trusted-host a", "--trusted-host a"),
@@ -114,13 +112,14 @@ def test_requirements_env_var_missing(monkeypatch: MonkeyPatch, tmp_path: Path)
assert filename.read_text() == "${ENV_VAR}"
-def test_requirements_txt_transitive(tmp_path: Path) -> None:
+@pytest.mark.parametrize("flag", ["-r", "--requirement"])
+def test_requirements_txt_transitive(tmp_path: Path, flag: str) -> None:
other_req = tmp_path / "other-requirements.txt"
other_req.write_text("magic\nmagical")
- req = RequirementsFile("-r other-requirements.txt", root=tmp_path)
+ req = RequirementsFile(f"{flag} other-requirements.txt", root=tmp_path)
assert req.validate_and_expand() == ["magic", "magical"]
with req.with_file() as filename:
- assert filename.read_text() == "-r other-requirements.txt"
+ assert filename.read_text() == f"{flag} other-requirements.txt"
@pytest.mark.parametrize(
@@ -137,3 +136,27 @@ def test_bad_line(raw: str) -> None:
req = RequirementsFile(raw)
with pytest.raises(ValueError, match=re.escape(raw)):
req.validate_and_expand()
+
+
+def test_legacy_requirement_file(tmp_path: Path, monkeypatch: MonkeyPatch) -> None:
+ monkeypatch.chdir(tmp_path)
+ (tmp_path / "requirement.txt").write_text("a")
+ raw = RequirementsFile("-rrequirement.txt")
+ assert raw.validate_and_expand() == ["a"]
+
+
+def test_legacy_constraint_file(tmp_path: Path, monkeypatch: MonkeyPatch) -> None:
+ monkeypatch.chdir(tmp_path)
+ (tmp_path / "constraint.txt").write_text("b")
+ raw = RequirementsFile("-cconstraint.txt")
+ assert raw.validate_and_expand() == ["b"]
+
+
+@pytest.mark.parametrize("flag", ["-c", "--constraint"])
+def test_constraint_txt_expanded(tmp_path: Path, flag: str) -> None:
+ other_req = tmp_path / "other.txt"
+ other_req.write_text("magic\nmagical")
+ req = RequirementsFile(f"{flag} other.txt", root=tmp_path)
+ assert req.validate_and_expand() == ["magic", "magical"]
+ with req.with_file() as filename:
+ assert filename.read_text() == f"{flag} other.txt"