Skip to content

Commit

Permalink
Add a test that six builtins were imported.
Browse files Browse the repository at this point in the history
  • Loading branch information
QuLogic committed Jun 12, 2015
1 parent e7c000d commit 410a278
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/iris/tests/test_coding_standards.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,10 @@ class TestFutureImports(unittest.TestCase):
r"print_function(,\s*unicode_literals)?\)$",
flags=re.MULTILINE)

six_import_pattern = re.compile(
r"^from six.moves import \(filter,\s*input,\s*map,\s*range,\s*zip\)$",
flags=re.MULTILINE)

def test_future_imports(self):
# Tests that every single Python file includes the appropriate
# __future__ import to enforce consistent behaviour.
Expand Down Expand Up @@ -407,9 +411,15 @@ def test_future_imports(self):
'test.'.format(full_fname))
failed = True

if re.search(self.six_import_pattern, content) is None:
print('The file {} has no valid six import '
'and has not been excluded from the imports '
'test.'.format(full_fname))
failed = True

if failed:
raise ValueError('There were __future__ import check failures. '
'See stdout.')
raise ValueError('There were Python 3 compatibility import check '
'failures. See stdout.')


if __name__ == '__main__':
Expand Down

0 comments on commit 410a278

Please sign in to comment.