|
| 1 | +# Copyright 2017 The Bazel Authors. All rights reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +import hashlib |
| 16 | +import os |
| 17 | +import unittest |
| 18 | + |
| 19 | + |
| 20 | +def TestData(name): |
| 21 | + return os.path.join(os.environ['TEST_SRCDIR'], 'io_bazel_rules_python', name) |
| 22 | + |
| 23 | + |
| 24 | +class WheelTest(unittest.TestCase): |
| 25 | + |
| 26 | + def test_piptool_matches(self): |
| 27 | + with open(TestData('rules_python/piptool.par'), 'r') as f: |
| 28 | + built = f.read() |
| 29 | + with open(TestData('tools/piptool.par'), 'r') as f: |
| 30 | + checked_in = f.read() |
| 31 | + self.assertEquals( |
| 32 | + hashlib.sha256(built).hexdigest(), hashlib.sha256(checked_in).hexdigest(), |
| 33 | + 'The checked in tools/piptool.par does not match the latest build.') |
| 34 | + |
| 35 | + def test_whltool_matches(self): |
| 36 | + with open(TestData('rules_python/whltool.par'), 'r') as f: |
| 37 | + built = f.read() |
| 38 | + with open(TestData('tools/whltool.par'), 'r') as f: |
| 39 | + checked_in = f.read() |
| 40 | + self.assertEquals( |
| 41 | + hashlib.sha256(built).hexdigest(), hashlib.sha256(checked_in).hexdigest(), |
| 42 | + 'The checked in tools/whltool.par does not match the latest build.') |
| 43 | + |
| 44 | +if __name__ == '__main__': |
| 45 | + unittest.main() |
0 commit comments