Merge "Replace parse_strtime with datetime.strptime"
This commit is contained in:
commit
6a1136cc60
|
@ -12,8 +12,6 @@
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from oslo_utils import timeutils
|
|
||||||
|
|
||||||
import keystone.tests.unit as tests
|
import keystone.tests.unit as tests
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,13 +19,13 @@ class TestTimeUtils(tests.BaseTestCase):
|
||||||
|
|
||||||
def test_parsing_date_strings_returns_a_datetime(self):
|
def test_parsing_date_strings_returns_a_datetime(self):
|
||||||
example_date_str = '2015-09-23T04:45:37.196621Z'
|
example_date_str = '2015-09-23T04:45:37.196621Z'
|
||||||
dt = timeutils.parse_strtime(example_date_str, fmt=tests.TIME_FORMAT)
|
dt = datetime.datetime.strptime(example_date_str, tests.TIME_FORMAT)
|
||||||
self.assertIsInstance(dt, datetime.datetime)
|
self.assertIsInstance(dt, datetime.datetime)
|
||||||
|
|
||||||
def test_parsing_invalid_date_strings_raises_a_ValueError(self):
|
def test_parsing_invalid_date_strings_raises_a_ValueError(self):
|
||||||
example_date_str = ''
|
example_date_str = ''
|
||||||
simple_format = '%Y'
|
simple_format = '%Y'
|
||||||
self.assertRaises(ValueError,
|
self.assertRaises(ValueError,
|
||||||
timeutils.parse_strtime,
|
datetime.datetime.strptime,
|
||||||
example_date_str,
|
example_date_str,
|
||||||
fmt=simple_format)
|
simple_format)
|
||||||
|
|
|
@ -12,11 +12,11 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import datetime
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
import oslo_context.context
|
import oslo_context.context
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
from oslo_utils import timeutils
|
|
||||||
from six.moves import http_client
|
from six.moves import http_client
|
||||||
from testtools import matchers
|
from testtools import matchers
|
||||||
import webtest
|
import webtest
|
||||||
|
@ -548,7 +548,7 @@ class RestfulTestCase(unit.SQLDriverOverrides, rest.RestfulTestCase,
|
||||||
|
|
||||||
def assertValidISO8601ExtendedFormatDatetime(self, dt):
|
def assertValidISO8601ExtendedFormatDatetime(self, dt):
|
||||||
try:
|
try:
|
||||||
return timeutils.parse_strtime(dt, fmt=TIME_FORMAT)
|
return datetime.datetime.strptime(dt, TIME_FORMAT)
|
||||||
except Exception:
|
except Exception:
|
||||||
msg = '%s is not a valid ISO 8601 extended format date time.' % dt
|
msg = '%s is not a valid ISO 8601 extended format date time.' % dt
|
||||||
raise AssertionError(msg)
|
raise AssertionError(msg)
|
||||||
|
|
Loading…
Reference in New Issue