forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_license.py
30 lines (22 loc) · 888 Bytes
/
test_license.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import io
import unittest
from torch.testing._internal.common_utils import TestCase, run_tests
try:
from third_party.build_bundled import create_bundled
except ImportError:
create_bundled = None
license_file = 'third_party/LICENSES_BUNDLED.txt'
class TestLicense(TestCase):
@unittest.skipIf(not create_bundled, "can only be run in a source tree")
def test_license_in_wheel(self):
current = io.StringIO()
create_bundled('third_party', current)
with open(license_file) as fid:
src_tree = fid.read()
if not src_tree == current.getvalue():
raise AssertionError(
f'the contents of "{license_file}" do not '
'match the current state of the third_party files. Use '
'"python third_party/build_bundled.py" to regenerate it')
if __name__ == '__main__':
run_tests()