/
/
/
1"""Tests for the requirements file generator."""
2
3from __future__ import annotations
4
5import pytest
6
7from scripts.gen_requirements_all import GIT_REPO_REGEX
8
9
10@pytest.mark.parametrize(
11 "line",
12 [
13 "git+https://github.com/owner/repo",
14 "git+https://github.com/owner/[email protected]",
15 "git+https://github.com/owner/some-repo@feature_branch",
16 ],
17)
18def test_git_repo_regex_matches(line: str) -> None:
19 """Valid git requirement lines are recognized."""
20 assert GIT_REPO_REGEX.match(line)
21
22
23@pytest.mark.parametrize(
24 "line",
25 [
26 # chars like ^ [ ] were accidentally accepted by the former @-_ char range
27 "git+https://github.com/owner/repo@v1^0",
28 "git+https://github.com/owner/repo@[tag]",
29 "git+https://example.com/repo; rm -rf /",
30 ],
31)
32def test_git_repo_regex_rejects(line: str) -> None:
33 """Lines with unexpected characters are not recognized as git requirements."""
34 assert not GIT_REPO_REGEX.match(line)
35