|
| 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', |
| 13 | + 'psutil': 'BSD3', |
| 14 | + 'setuptools': "MIT", |
| 15 | + 'typing-extensions': "PSFL", |
| 16 | + 'PyAudio': "MIT" |
| 17 | +} |
| 18 | +# explicitly allow these packages that would fail otherwise |
| 19 | +whitelist = [ |
| 20 | + 'idna', # BSD-like |
| 21 | + 'python-dateutil', # 'Simplified BSD' |
| 22 | + 'pycryptodomex', # 'BSD, Public Domain', |
| 23 | +] |
| 24 | + |
| 25 | +# validation flags |
| 26 | +allow_nonfree = False |
| 27 | +allow_viral = False |
| 28 | +allow_unknown = False |
| 29 | +allow_unlicense = True |
| 30 | +allow_ambiguous = False |
| 31 | + |
| 32 | +pkg_name = "hivemind_webchat" |
| 33 | + |
| 34 | + |
| 35 | +class TestLicensing(unittest.TestCase): |
| 36 | + @classmethod |
| 37 | + def setUpClass(self): |
| 38 | + licheck = LicenseChecker(pkg_name, |
| 39 | + license_overrides=license_overrides, |
| 40 | + whitelisted_packages=whitelist, |
| 41 | + allow_ambiguous=allow_ambiguous, |
| 42 | + allow_unlicense=allow_unlicense, |
| 43 | + allow_unknown=allow_unknown, |
| 44 | + allow_viral=allow_viral, |
| 45 | + allow_nonfree=allow_nonfree) |
| 46 | + print("Package", pkg_name) |
| 47 | + print("Version", licheck.version) |
| 48 | + print("License", licheck.license) |
| 49 | + print("Transient Requirements (dependencies of dependencies)") |
| 50 | + pprint(licheck.transient_dependencies) |
| 51 | + self.licheck = licheck |
| 52 | + |
| 53 | + def test_license_compliance(self): |
| 54 | + print("Package Versions") |
| 55 | + pprint(self.licheck.versions) |
| 56 | + |
| 57 | + print("Dependency Licenses") |
| 58 | + pprint(self.licheck.licenses) |
| 59 | + |
| 60 | + self.licheck.validate() |
0 commit comments