Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions lib/iris/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import logging
import os
import os.path
import re
import shutil
import subprocess
import sys
Expand Down Expand Up @@ -205,6 +206,19 @@ def setUpClass(cls):
iris.site_configuration['cf_profile'] = None

def _assert_str_same(self, reference_str, test_str, reference_filename, type_comparison_name='Strings'):
# Work around to deal with alterations to attribute typing in
# netcdf4python, introduced in 1.1 and present in 1.2. see:
# https://github.com/Unidata/netcdf-c/issues/298
# https://github.com/Unidata/netcdf4-python/issues/529
# https://github.com/Unidata/netcdf4-python/issues/575
# amongst others for further details.
if type_comparison_name == 'CDL' and reference_str != test_str:
# Match where a new line contains only:
# tab|tab|string |attr_definition.
pattern = re.compile('(^\t\t)string (.+)$', re.MULTILINE)
# Replace with tab|tab|attr_definition.
replacement = r'\t\t\2'
Copy link
Member

@QuLogic QuLogic Oct 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A raw string means the tab isn't interpreted; how does it pass?

test_str = re.sub(pattern, replacement, test_str)
if reference_str != test_str:
diff = ''.join(difflib.unified_diff(reference_str.splitlines(1), test_str.splitlines(1),
'Reference', 'Test result', '', '', 0))
Expand Down