-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test to keep requirements in sync (#465)
- Loading branch information
Showing
3 changed files
with
31 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import tomllib | ||
|
||
|
||
def test_requirements_txt_pyproject_toml(): | ||
with open("requirements.txt", "r", encoding="utf-8") as req_file: | ||
reqtxt_reqs = req_file.readlines() | ||
reqtxt_reqs = list(map(str.strip, reqtxt_reqs)) | ||
reqtxt_reqs.sort() | ||
with open("pyproject.toml", "rb") as pyproject_file: | ||
pyproject_reqs = tomllib.load(pyproject_file)["project"]["dependencies"] | ||
pyproject_reqs.sort() | ||
# assert len(reqtxt_reqs) == len(pyproject_reqs) # same number of requirements | ||
assert ( | ||
set(reqtxt_reqs) - set(pyproject_reqs) == set() | ||
) # things in reqtxt but not in pyproject | ||
assert ( | ||
set(pyproject_reqs) - set(reqtxt_reqs) == set() | ||
) # things in pyproject but not in reqtxt | ||
assert ( | ||
reqtxt_reqs == pyproject_reqs | ||
) # final check. this one is actually enough, but let's help us debug by finding which test fails, ok? |