Skip to content
Open
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
24 changes: 12 additions & 12 deletions test_aodntools/ncwriter/test_template.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -102,7 +102,7 @@ def test_init_from_dicts_validation(self):

def test_invalid_json(self):
error_pattern = r"invalid JSON file '{}'".format(re.escape(BAD_JSON))
self.assertRaisesRegexp(ValueError, error_pattern, DatasetTemplate.from_json, BAD_JSON)
self.assertRaisesRegex(ValueError, error_pattern, DatasetTemplate.from_json, BAD_JSON)

def test_init_from_json(self):
template = DatasetTemplate.from_json(TEMPLATE_JSON)
Expand DownExpand Up@@ -278,12 +278,12 @@ def test_ensure_completeness(self):
self.assertEqual([], template.variables['Y']['_dimensions'])

template.variables = {'Z': {'_dimensions': [], '_data': None}}
self.assertRaisesRegexp(ValidationError, r"No data type information for variable 'Z'",
template.ensure_completeness)
self.assertRaisesRegex(ValidationError, r"No data type information for variable 'Z'",
template.ensure_completeness)

template.variables = {'Z': {'_dimensions': []}}
self.assertRaisesRegexp(ValidationError, r"No data specified for variable 'Z'",
template.ensure_completeness)
self.assertRaisesRegex(ValidationError, r"No data specified for variable 'Z'",
template.ensure_completeness)

def test_ensure_consistency(self):
template = DatasetTemplate()
Expand DownExpand Up@@ -314,21 +314,21 @@ def test_ensure_consistency(self):
self.assertIs(empty, template.variables['EMPTY'])

template.variables['X']['_data'] = self.values1
self.assertRaisesRegexp(ValueError, 'inconsistent with dimension sizes defined in template',
template.ensure_consistency) # now should fail because dim X is already set
self.assertRaisesRegex(ValueError, 'inconsistent with dimension sizes defined in template',
template.ensure_consistency) # now should fail because dim X is already set

template.variables = {
'Z': {'_dimensions': ["NOSUCHTHING"], '_data': self.values10}
}
self.assertRaisesRegexp(ValidationError, 'undefined dimensions', template.ensure_consistency)
self.assertRaisesRegex(ValidationError, 'undefined dimensions', template.ensure_consistency)

template.variables = {
'W': {'_dimensions': ['X'], '_data': np.arange(20).reshape((10,2))}
}
self.assertRaisesRegexp(ValueError,
"Variable 'W' has 1 dimensions, but value array has 2 dimensions.",
template.ensure_consistency
)
self.assertRaisesRegex(ValueError,
"Variable 'W' has 1 dimensions, but value array has 2 dimensions.",
template.ensure_consistency
)


class TestDataValues(TemplateTestCase):
Expand Down