diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000000000000000000000000000000000..03eb1cc1e58532ee5f0e601c482a77093e01f32e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +language: python + +python: 2.7 + +cache: pip + +install: + - pip install lxml six + +script: + - cd tests && python test.py diff --git a/tests/test.py b/tests/test.py index ffa9bf7ed869f6ff0a68093e6ec33f8a5d2f10f7..fcbe202cea8e8bd58efd8ed2d7cff94d1526dc33 100755 --- a/tests/test.py +++ b/tests/test.py @@ -927,8 +927,9 @@ class GenTest(unittest.TestCase): def compareFiles(self, left, right, ignore=None): with open(left) as left_file: with open(right) as right_file: - diffs = difflib.unified_diff( - left_file.readlines(), right_file.readlines()) + lf = strip_build_comments(left_file.readlines()) + rf = strip_build_comments(right_file.readlines()) + diffs = difflib.unified_diff(lf, rf) diffs = list(diffs) if diffs: diffs = ''.join(diffs[2:12]) @@ -939,6 +940,29 @@ class GenTest(unittest.TestCase): os.remove(filename) +def strip_build_comments(lines): + """ + Remove lines in Python file which may vary on different systems. + """ + assert isinstance(lines, list), type(lines) + if '#!/usr/bin/env python' in lines[0]: + + # This line contains sometimes package version + n = 3 + int('coding: utf-8' in lines[1]) + assert lines[n].startswith('# Generated '), repr(lines[n]) + del lines[n] + + # Next line contains Python version and build information + assert lines[n].startswith('# Python '), repr(lines[n]) + del lines[n] + + # Another line assumes we have certain name for directory + n = lines.index('# Current working directory (os.getcwd()):\n') + del lines[n + 1] + + return lines + + # Make the test suite. def suite(): # The following is obsolete. See Lib/unittest.py.