|
| 1 | +import unittest |
| 2 | +from pprint import pprint |
| 3 | + |
| 4 | +from lichecker import LicenseChecker |
| 5 | + |
| 6 | +# these packages dont define license in setup.py |
| 7 | +# manually verified and injected |
| 8 | +license_overrides = { |
| 9 | + "kthread": "MIT", |
| 10 | + 'yt-dlp': "Unlicense", |
| 11 | + 'pyxdg': 'GPL-2.0', |
| 12 | + 'ptyprocess': 'ISC license', |
| 13 | + 'psutil': 'BSD3' |
| 14 | +} |
| 15 | +# explicitly allow these packages that would fail otherwise |
| 16 | +whitelist = [] |
| 17 | + |
| 18 | +# validation flags |
| 19 | +allow_nonfree = False |
| 20 | +allow_viral = False |
| 21 | +allow_unknown = False |
| 22 | +allow_unlicense = True |
| 23 | +allow_ambiguous = False |
| 24 | + |
| 25 | +pkg_name = "ovos_utils" |
| 26 | + |
| 27 | + |
| 28 | +class TestLicensing(unittest.TestCase): |
| 29 | + @classmethod |
| 30 | + def setUpClass(self): |
| 31 | + licheck = LicenseChecker(pkg_name, |
| 32 | + license_overrides=license_overrides, |
| 33 | + whitelisted_packages=whitelist, |
| 34 | + allow_ambiguous=allow_ambiguous, |
| 35 | + allow_unlicense=allow_unlicense, |
| 36 | + allow_unknown=allow_unknown, |
| 37 | + allow_viral=allow_viral, |
| 38 | + allow_nonfree=allow_nonfree) |
| 39 | + print("Package", pkg_name) |
| 40 | + print("Version", licheck.version) |
| 41 | + print("License", licheck.license) |
| 42 | + print("Transient Requirements (dependencies of dependencies)") |
| 43 | + pprint(licheck.transient_dependencies) |
| 44 | + self.licheck = licheck |
| 45 | + |
| 46 | + def test_license_compliance(self): |
| 47 | + print("Package Versions") |
| 48 | + pprint(self.licheck.versions) |
| 49 | + |
| 50 | + print("Dependency Licenses") |
| 51 | + pprint(self.licheck.licenses) |
| 52 | + |
| 53 | + self.licheck.validate() |
0 commit comments