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 22, 2015
1 parent d517878 commit 6c02f5d
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, input, map, range, zip\) # noqa$",
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 6c02f5d

Please sign in to comment.