Skip to content

Commit

Permalink
Merge pull request #222 from SuperSandro2000/babel-12-2
Browse files Browse the repository at this point in the history
Fix tests against babel 12.2.x
  • Loading branch information
TkTech committed Apr 3, 2023
2 parents a57e3ee + 756cace commit 47c50af
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ include = [
python = "^3.7"
pytz = "^2022.7"
Flask = "^2.0.0"
Babel = "^2.11.0"
Babel = "^2.12.0"
Jinja2 = "^3.1.2"

[tool.poetry.dev-dependencies]
Expand Down
16 changes: 8 additions & 8 deletions tests/test_date_formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ def test_basics():
delta = timedelta(days=6)

with app.test_request_context():
assert babel.format_datetime(d) == 'Apr 12, 2010, 1:46:00 PM'
assert babel.format_datetime(d) == 'Apr 12, 2010, 1:46:00\u202fPM'
assert babel.format_date(d) == 'Apr 12, 2010'
assert babel.format_time(d) == '1:46:00 PM'
assert babel.format_time(d) == '1:46:00\u202fPM'
assert babel.format_timedelta(delta) == '1 week'
assert babel.format_timedelta(delta, threshold=1) == '6 days'

with app.test_request_context():
get_babel(app).default_timezone = 'Europe/Vienna'
assert babel.format_datetime(d) == 'Apr 12, 2010, 3:46:00 PM'
assert babel.format_datetime(d) == 'Apr 12, 2010, 3:46:00\u202fPM'
assert babel.format_date(d) == 'Apr 12, 2010'
assert babel.format_time(d) == '3:46:00 PM'
assert babel.format_time(d) == '3:46:00\u202fPM'

with app.test_request_context():
get_babel(app).default_locale = 'de_DE'
assert babel.format_datetime(d, 'long') == \
'12. April 2010 um 15:46:00 MESZ'
'12. April 2010, 15:46:00 MESZ'


def test_custom_formats():
Expand Down Expand Up @@ -64,7 +64,7 @@ def select_timezone():
get_babel(app).timezone_selector = select_timezone

with app.test_request_context():
assert babel.format_datetime(d) == 'Apr 12, 2010, 1:46:00 PM'
assert babel.format_datetime(d) == 'Apr 12, 2010, 1:46:00\u202fPM'

the_locale = 'de_DE'
the_timezone = 'Europe/Vienna'
Expand All @@ -78,7 +78,7 @@ def test_refreshing():
babel.Babel(app)
d = datetime(2010, 4, 12, 13, 46)
with app.test_request_context():
assert babel.format_datetime(d) == 'Apr 12, 2010, 1:46:00 PM'
assert babel.format_datetime(d) == 'Apr 12, 2010, 1:46:00\u202fPM'
get_babel(app).default_timezone = 'Europe/Vienna'
babel.refresh()
assert babel.format_datetime(d) == 'Apr 12, 2010, 3:46:00 PM'
assert babel.format_datetime(d) == 'Apr 12, 2010, 3:46:00\u202fPM'

0 comments on commit 47c50af

Please sign in to comment.