@@ -13,44 +13,46 @@ def test_basics():
1313 delta = timedelta (days = 6 )
1414
1515 with app .test_request_context ():
16- assert babel .format_datetime (d ) == " Apr 12, 2010, 1:46:00\u202f PM"
17- assert babel .format_date (d ) == " Apr 12, 2010"
18- assert babel .format_time (d ) == " 1:46:00\u202f PM"
19- assert babel .format_timedelta (delta ) == " 1 week"
20- assert babel .format_timedelta (delta , threshold = 1 ) == " 6 days"
16+ assert babel .format_datetime (d ) == ' Apr 12, 2010, 1:46:00\u202f PM'
17+ assert babel .format_date (d ) == ' Apr 12, 2010'
18+ assert babel .format_time (d ) == ' 1:46:00\u202f PM'
19+ assert babel .format_timedelta (delta ) == ' 1 week'
20+ assert babel .format_timedelta (delta , threshold = 1 ) == ' 6 days'
2121
2222 with app .test_request_context ():
23- get_babel (app ).default_timezone = " Europe/Vienna"
24- assert babel .format_datetime (d ) == " Apr 12, 2010, 3:46:00\u202f PM"
25- assert babel .format_date (d ) == " Apr 12, 2010"
26- assert babel .format_time (d ) == " 3:46:00\u202f PM"
23+ get_babel (app ).default_timezone = ' Europe/Vienna'
24+ assert babel .format_datetime (d ) == ' Apr 12, 2010, 3:46:00\u202f PM'
25+ assert babel .format_date (d ) == ' Apr 12, 2010'
26+ assert babel .format_time (d ) == ' 3:46:00\u202f PM'
2727
2828 with app .test_request_context ():
29- get_babel (app ).default_locale = "de_DE"
30- assert babel .format_datetime (d , "long" ) == "12. April 2010, 15:46:00 MESZ"
29+ get_babel (app ).default_locale = 'de_DE'
30+ assert babel .format_datetime (d , 'long' ) == \
31+ '12. April 2010, 15:46:00 MESZ'
3132
3233
3334def test_custom_formats ():
3435 app = flask .Flask (__name__ )
3536 app .config .update (
36- BABEL_DEFAULT_LOCALE = "en_US" , BABEL_DEFAULT_TIMEZONE = "Pacific/Johnston"
37+ BABEL_DEFAULT_LOCALE = 'en_US' ,
38+ BABEL_DEFAULT_TIMEZONE = 'Pacific/Johnston'
3739 )
3840 b = babel .Babel (app )
39- b .date_formats [" datetime" ] = " long"
40- b .date_formats [" datetime.long" ] = " MMMM d, yyyy h:mm:ss a"
41+ b .date_formats [' datetime' ] = ' long'
42+ b .date_formats [' datetime.long' ] = ' MMMM d, yyyy h:mm:ss a'
4143 d = datetime (2010 , 4 , 12 , 13 , 46 )
4244
4345 with app .test_request_context ():
44- assert babel .format_datetime (d ) == " April 12, 2010 3:46:00 AM"
46+ assert babel .format_datetime (d ) == ' April 12, 2010 3:46:00 AM'
4547
4648
4749def test_custom_locale_selector ():
4850 app = flask .Flask (__name__ )
4951 b = babel .Babel (app )
5052 d = datetime (2010 , 4 , 12 , 13 , 46 )
5153
52- the_timezone = " UTC"
53- the_locale = " en_US"
54+ the_timezone = ' UTC'
55+ the_locale = ' en_US'
5456
5557 def select_locale ():
5658 return the_locale
@@ -62,21 +64,21 @@ def select_timezone():
6264 get_babel (app ).timezone_selector = select_timezone
6365
6466 with app .test_request_context ():
65- assert babel .format_datetime (d ) == " Apr 12, 2010, 1:46:00\u202f PM"
67+ assert babel .format_datetime (d ) == ' Apr 12, 2010, 1:46:00\u202f PM'
6668
67- the_locale = " de_DE"
68- the_timezone = " Europe/Vienna"
69+ the_locale = ' de_DE'
70+ the_timezone = ' Europe/Vienna'
6971
7072 with app .test_request_context ():
71- assert babel .format_datetime (d ) == " 12.04.2010, 15:46:00"
73+ assert babel .format_datetime (d ) == ' 12.04.2010, 15:46:00'
7274
7375
7476def test_refreshing ():
7577 app = flask .Flask (__name__ )
7678 babel .Babel (app )
7779 d = datetime (2010 , 4 , 12 , 13 , 46 )
7880 with app .test_request_context ():
79- assert babel .format_datetime (d ) == " Apr 12, 2010, 1:46:00\u202f PM"
80- get_babel (app ).default_timezone = " Europe/Vienna"
81+ assert babel .format_datetime (d ) == ' Apr 12, 2010, 1:46:00\u202f PM'
82+ get_babel (app ).default_timezone = ' Europe/Vienna'
8183 babel .refresh ()
82- assert babel .format_datetime (d ) == " Apr 12, 2010, 3:46:00\u202f PM"
84+ assert babel .format_datetime (d ) == ' Apr 12, 2010, 3:46:00\u202f PM'
0 commit comments