Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 77d0887

Browse files
committed
Add tox/CI test for license file
1 parent 3324bb6 commit 77d0887

4 files changed

Lines changed: 34 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ jobs:
7575
toxenv: py38-tests
7676
- name: 3.8
7777
toxenv: py38-tests_nongpl
78+
- name: 3.8
79+
toxenv: check-package-license-file
7880
exclude:
7981
# Building on Windows isn't supported, and 3.5/PyPy on Windows
8082
# seem to fail with silent obscure errors.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ _static
33
_templates
44

55
TODO
6+
license_report.json

test_license.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python3
2+
3+
"""Test that this package's license file is properly detected by pip-licenses.
4+
5+
This file assumes that pip-licenses has already been run (in a tox env) and
6+
generated license_report.json.
7+
"""
8+
9+
import json
10+
from pathlib import Path
11+
12+
13+
def main():
14+
packages = json.loads(
15+
(Path(__file__).resolve().parent / 'license_report.json').read_text())
16+
for package in packages:
17+
if package['Name'] == 'jsonschema':
18+
assert package['LicenseFile'] != 'UNKNOWN'
19+
20+
21+
if __name__ == '__main__':
22+
main()

tox.ini

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,12 @@ commands =
126126
{envpython} -m coverage run --rcfile={toxinidir}/.coveragerc -m twisted.trial jsonschema
127127
{envpython} -m coverage xml -o {envtmpdir}/coverage.xml
128128
codecov --required --disable gcov --file {envtmpdir}/coverage.xml
129+
130+
[testenv:check-package-license-file]
131+
recreate = True
132+
deps =
133+
pip-licenses
134+
commands =
135+
pip install {toxinidir}
136+
pip-licenses --from=mixed --with-license-file --format=json --output-file={toxinidir}/license_report.json
137+
{envpython} {toxinidir}/test_license.py

0 commit comments

Comments
 (0)