File: test_day_periods.py

package info (click to toggle)
python-babel 2.6.0%2Bdfsg.1-1%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 164,640 kB
  • sloc: xml: 1,848,178; python: 11,849; makefile: 213; sh: 44
file content (18 lines) | stat: -rw-r--r-- 644 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# -- encoding: UTF-8 --
from datetime import time

import babel.dates as dates
import pytest


@pytest.mark.parametrize("locale, time, expected_period_id", [
    ("de", time(7, 42), "morning1"),  # (from, before)
    ("de", time(3, 11), "night1"),  # (after, before)
    ("fi", time(0), "midnight"),  # (at)
    ("en_US", time(12), "noon"),  # (at)
    ("agq", time(10), "am"),  # no periods defined
    ("agq", time(22), "pm"),  # no periods defined
    ("am", time(14), "afternoon1"),  # (before, after)
])
def test_day_period_rules(locale, time, expected_period_id):
    assert dates.get_period_id(time, locale=locale) == expected_period_id