Skip to content

Commit

Permalink
use six
Browse files Browse the repository at this point in the history
  • Loading branch information
ocefpaf committed May 30, 2018
1 parent 8fcb5b0 commit 4d9df15
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions nc_time_axis/tests/unit/test_NetCDFTimeConverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@

from __future__ import (absolute_import, division, print_function)
from six.moves import (filter, input, map, range, zip) # noqa
from six import assertRaisesRegex

import sys
import unittest

import cftime
import numpy as np

from nc_time_axis import NetCDFTimeConverter, CalendarDateTime

if sys.version_info[:2] == (2, 7):
unittest.TestCase.assertRaisesRegex = unittest.TestCase.assertRaisesRegexp


class Test_axisinfo(unittest.TestCase):
def test_axis_default_limits(self):
Expand Down Expand Up @@ -60,7 +57,7 @@ def test_nonequal_calendars(self):
unit = 'days since 2000-01-01'
val = [CalendarDateTime(cftime.datetime(2014, 8, 12), calendar_1),
CalendarDateTime(cftime.datetime(2014, 8, 13), calendar_2)]
with self.assertRaisesRegex(ValueError, 'not all equal'):
with assertRaisesRegex(self, ValueError, 'not all equal'):
NetCDFTimeConverter().default_units(val, None)


Expand Down Expand Up @@ -102,14 +99,14 @@ def test_non_cftime_datetime(self):
val = CalendarDateTime(4, '360_day')
msg = 'The datetime attribute of the CalendarDateTime object must ' \
'be of type `cftime.datetime`.'
with self.assertRaisesRegex(ValueError, msg):
with assertRaisesRegex(self, ValueError, msg):
result = NetCDFTimeConverter().convert(val, None, None)

def test_non_CalendarDateTime(self):
val = cftime.datetime(1988, 5, 6)
msg = 'The values must be numbers or instances of ' \
'"nc_time_axis.CalendarDateTime".'
with self.assertRaisesRegex(ValueError, msg):
with assertRaisesRegex(self, ValueError, msg):
result = NetCDFTimeConverter().convert(val, None, None)


Expand Down

0 comments on commit 4d9df15

Please sign in to comment.