Skip to content

Commit 6564798

Browse files
committed
update tests, all passing
1 parent 145cdb4 commit 6564798

File tree

6 files changed

+21
-219
lines changed

6 files changed

+21
-219
lines changed

licensecheck/cli.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,15 @@ def cli() -> None: # pragma: no cover
3232
help=f"Output format. one of: {', '.join(list(formatter.formatMap))}. default=simple",
3333
)
3434
parser.add_argument(
35-
"--deps-file",
36-
"-i",
37-
"-d",
38-
help="Filename to read from (omit for stdin)",
35+
"--requirements-paths",
36+
"-r",
37+
help="Filenames to read from (omit for stdin)",
3938
nargs="+",
4039
)
4140
parser.add_argument(
4241
"--groups",
4342
"-g",
44-
help="Select groups from supported files",
43+
help="Select groups/extras from supported files",
4544
nargs="+",
4645
)
4746
parser.add_argument(
@@ -91,7 +90,13 @@ def cli() -> None: # pragma: no cover
9190
action="store_true",
9291
)
9392
args = vars(parser.parse_args())
94-
sysexit(main(args))
93+
stdin_path = Path("__stdin__")
94+
if stdin:
95+
stdin_path.write_text("\n".join(stdin.readlines()), "utf-8")
96+
ec = main(args)
97+
stdin_path.unlink(missing_ok=True)
98+
99+
sysexit(ec)
95100

96101

97102
def main(args: dict) -> int:
@@ -118,8 +123,8 @@ def main(args: dict) -> int:
118123
simpleConf = SimpleConf(configparser, "licensecheck", args)
119124

120125
# File
121-
input_file = (
122-
simpleConf.get("deps_file") or stdin
126+
requirements_paths = (
127+
simpleConf.get("requirements_paths") or ["__stdin__"]
123128
)
124129
output_file = (
125130
stdout
@@ -135,7 +140,7 @@ def getFromConfig(key: str) -> list[types.ucstr]:
135140
return list(map(types.ucstr, simpleConf.get(key, [])))
136141

137142
incompatible, depsWithLicenses = get_deps.check(
138-
input_file=input_file,
143+
requirements_paths=requirements_paths,
139144
groups=simpleConf.get("groups", []),
140145
this_license=this_license,
141146
ignore_packages=getFromConfig("ignore_packages"),

tests/data/pep631_socks/pyproject.toml

Lines changed: 0 additions & 40 deletions
This file was deleted.

tests/test_cli.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,22 @@ def aux_file(file: str) -> str:
1919

2020

2121
test_data = [
22-
({"license": "MIT", "file": aux_file("test_main_tc1.txt")}, 0),
22+
({"license": "MIT", "file": aux_file("test_main_tc1.txt"), "requirements_paths": ["pyproject.toml"]}, 0),
2323
(
2424
{
2525
"license": "BSD",
2626
"file": aux_file("test_main_tc3.txt"),
27-
"ignore-packages": ["requests"],
28-
"ignore-licenses": ["GPL"],
27+
"requirements_paths": ["pyproject.toml"],
28+
"ignore_packages": ["requests"],
29+
"ignore_licenses": ["GPL"],
2930
},
3031
0,
3132
),
3233
(
3334
{
3435
"license": "GPL",
3536
"file": aux_file("test_main_tc4.json"),
37+
"requirements_paths": ["pyproject.toml"],
3638
"format": "json",
3739
"hide_output_parameters": ["size", "version", "namever"],
3840
},

tests/test_get_reqs.py

Lines changed: 0 additions & 166 deletions
This file was deleted.

tests/test_resolvers_native.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
def test_doGetReqs_PEP631() -> None:
1212
extras = ["socks"]
1313
pyproject = tomli.loads((THISDIR / "data/pep631_socks.toml").read_text(encoding="utf-8"))
14-
requirementsPaths = []
14+
requirementsPaths = [(THISDIR / "data/pep631_socks.toml")]
1515
skipDependencies = [types.ucstr("TOSKIP")]
1616

1717
assert get_deps.get_reqs(skipDependencies, extras, requirementsPaths, pyproject) == {

tests/test_resolvers_uv.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ def test_issue_84() -> None:
157157
"KOMBU",
158158
"PROMPT-TOOLKIT",
159159
"PYTZ",
160+
"TZDATA",
160161
"VINE",
161162
"WCWIDTH",
162163
}

0 commit comments

Comments
 (0)