INCR-200 Migrate common/djangoapps/util/tests and migrations
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
Tests for util.date_utils
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import unittest
|
||||
from datetime import datetime, timedelta, tzinfo
|
||||
|
||||
@@ -130,7 +132,7 @@ class StrftimeLocalizedTest(unittest.TestCase):
|
||||
)
|
||||
def test_usual_strftime_behavior(self, fmt_expected):
|
||||
(fmt, expected) = fmt_expected
|
||||
dtime = datetime(2013, 02, 14, 16, 41, 17)
|
||||
dtime = datetime(2013, 2, 14, 16, 41, 17)
|
||||
self.assertEqual(expected, strftime_localized(dtime, fmt))
|
||||
# strftime doesn't like Unicode, so do the work in UTF8.
|
||||
self.assertEqual(expected, dtime.strftime(fmt.encode('utf8')).decode('utf8'))
|
||||
@@ -144,7 +146,7 @@ class StrftimeLocalizedTest(unittest.TestCase):
|
||||
)
|
||||
def test_shortcuts(self, fmt_expected):
|
||||
(fmt, expected) = fmt_expected
|
||||
dtime = datetime(2013, 02, 14, 16, 41, 17)
|
||||
dtime = datetime(2013, 2, 14, 16, 41, 17)
|
||||
self.assertEqual(expected, strftime_localized(dtime, fmt))
|
||||
|
||||
@patch('util.date_utils.pgettext', fake_pgettext(translations={
|
||||
@@ -163,7 +165,7 @@ class StrftimeLocalizedTest(unittest.TestCase):
|
||||
)
|
||||
def test_translated_words(self, fmt_expected):
|
||||
(fmt, expected) = fmt_expected
|
||||
dtime = datetime(2013, 02, 14, 16, 41, 17)
|
||||
dtime = datetime(2013, 2, 14, 16, 41, 17)
|
||||
self.assertEqual(expected, strftime_localized(dtime, fmt))
|
||||
|
||||
@patch('util.date_utils.ugettext', fake_ugettext(translations={
|
||||
@@ -183,7 +185,7 @@ class StrftimeLocalizedTest(unittest.TestCase):
|
||||
)
|
||||
def test_translated_formats(self, fmt_expected):
|
||||
(fmt, expected) = fmt_expected
|
||||
dtime = datetime(2013, 02, 14, 16, 41, 17)
|
||||
dtime = datetime(2013, 2, 14, 16, 41, 17)
|
||||
self.assertEqual(expected, strftime_localized(dtime, fmt))
|
||||
|
||||
@patch('util.date_utils.ugettext', fake_ugettext(translations={
|
||||
@@ -196,7 +198,7 @@ class StrftimeLocalizedTest(unittest.TestCase):
|
||||
)
|
||||
def test_recursion_protection(self, fmt_expected):
|
||||
(fmt, expected) = fmt_expected
|
||||
dtime = datetime(2013, 02, 14, 16, 41, 17)
|
||||
dtime = datetime(2013, 2, 14, 16, 41, 17)
|
||||
self.assertEqual(expected, strftime_localized(dtime, fmt))
|
||||
|
||||
@ddt.data(
|
||||
@@ -205,6 +207,6 @@ class StrftimeLocalizedTest(unittest.TestCase):
|
||||
"%Y/%m/%d%",
|
||||
)
|
||||
def test_invalid_format_strings(self, fmt):
|
||||
dtime = datetime(2013, 02, 14, 16, 41, 17)
|
||||
dtime = datetime(2013, 2, 14, 16, 41, 17)
|
||||
with self.assertRaises(ValueError):
|
||||
strftime_localized(dtime, fmt)
|
||||
|
||||
Reference in New Issue
Block a user