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