Skip to content

Commit 7d7926a

Browse files
Expand Hong Kong, ChineseCN and ChineseTW Locale Test Cases (#1076)
Co-authored-by: Anish Nyayachavadi <[email protected]>
1 parent fecbada commit 7d7926a

File tree

1 file changed

+150
-0
lines changed

1 file changed

+150
-0
lines changed

tests/test_locales.py

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2018,6 +2018,56 @@ def test_format_timeframe(self):
20182018
assert self.locale._format_timeframe("year", 1) == "1年"
20192019
assert self.locale._format_timeframe("years", 12) == "12年"
20202020

2021+
assert self.locale._format_timeframe("second", -1) == "1秒"
2022+
assert self.locale._format_timeframe("seconds", -30) == "30秒"
2023+
assert self.locale._format_timeframe("minute", -1) == "1分鐘"
2024+
assert self.locale._format_timeframe("minutes", -40) == "40分鐘"
2025+
assert self.locale._format_timeframe("hour", -1) == "1小時"
2026+
assert self.locale._format_timeframe("hours", -23) == "23小時"
2027+
assert self.locale._format_timeframe("day", -1) == "1天"
2028+
assert self.locale._format_timeframe("days", -12) == "12天"
2029+
assert self.locale._format_timeframe("week", -1) == "1星期"
2030+
assert self.locale._format_timeframe("weeks", -38) == "38星期"
2031+
assert self.locale._format_timeframe("month", -1) == "1個月"
2032+
assert self.locale._format_timeframe("months", -11) == "11個月"
2033+
assert self.locale._format_timeframe("year", -1) == "1年"
2034+
assert self.locale._format_timeframe("years", -12) == "12年"
2035+
2036+
def test_format_relative_now(self):
2037+
assert self.locale._format_relative("剛才", "now", 0) == "剛才"
2038+
2039+
def test_format_relative_past(self):
2040+
assert self.locale._format_relative("1秒", "second", 1) == "1秒後"
2041+
assert self.locale._format_relative("2秒", "seconds", 2) == "2秒後"
2042+
assert self.locale._format_relative("1分鐘", "minute", 1) == "1分鐘後"
2043+
assert self.locale._format_relative("2分鐘", "minutes", 2) == "2分鐘後"
2044+
assert self.locale._format_relative("1小時", "hour", 1) == "1小時後"
2045+
assert self.locale._format_relative("2小時", "hours", 2) == "2小時後"
2046+
assert self.locale._format_relative("1天", "day", 1) == "1天後"
2047+
assert self.locale._format_relative("2天", "days", 2) == "2天後"
2048+
assert self.locale._format_relative("1星期", "week", 1) == "1星期後"
2049+
assert self.locale._format_relative("2星期", "weeks", 2) == "2星期後"
2050+
assert self.locale._format_relative("1個月", "month", 1) == "1個月後"
2051+
assert self.locale._format_relative("2個月", "months", 2) == "2個月後"
2052+
assert self.locale._format_relative("1年", "year", 1) == "1年後"
2053+
assert self.locale._format_relative("2年", "years", 2) == "2年後"
2054+
2055+
def test_format_relative_future(self):
2056+
assert self.locale._format_relative("1秒", "second", -1) == "1秒前"
2057+
assert self.locale._format_relative("2秒", "seconds", -2) == "2秒前"
2058+
assert self.locale._format_relative("1分鐘", "minute", -1) == "1分鐘前"
2059+
assert self.locale._format_relative("2分鐘", "minutes", -2) == "2分鐘前"
2060+
assert self.locale._format_relative("1小時", "hour", -1) == "1小時前"
2061+
assert self.locale._format_relative("2小時", "hours", -2) == "2小時前"
2062+
assert self.locale._format_relative("1天", "day", -1) == "1天前"
2063+
assert self.locale._format_relative("2天", "days", -2) == "2天前"
2064+
assert self.locale._format_relative("1星期", "week", -1) == "1星期前"
2065+
assert self.locale._format_relative("2星期", "weeks", -2) == "2星期前"
2066+
assert self.locale._format_relative("1個月", "month", -1) == "1個月前"
2067+
assert self.locale._format_relative("2個月", "months", -2) == "2個月前"
2068+
assert self.locale._format_relative("1年", "year", -1) == "1年前"
2069+
assert self.locale._format_relative("2年", "years", -2) == "2年前"
2070+
20212071

20222072
@pytest.mark.usefixtures("lang_locale")
20232073
class TestChineseTWLocale:
@@ -2038,6 +2088,56 @@ def test_format_timeframe(self):
20382088
assert self.locale._format_timeframe("year", 1) == "1年"
20392089
assert self.locale._format_timeframe("years", 12) == "12年"
20402090

2091+
assert self.locale._format_timeframe("second", -1) == "1秒"
2092+
assert self.locale._format_timeframe("seconds", -30) == "30秒"
2093+
assert self.locale._format_timeframe("minute", -1) == "1分鐘"
2094+
assert self.locale._format_timeframe("minutes", -40) == "40分鐘"
2095+
assert self.locale._format_timeframe("hour", -1) == "1小時"
2096+
assert self.locale._format_timeframe("hours", -23) == "23小時"
2097+
assert self.locale._format_timeframe("day", -1) == "1天"
2098+
assert self.locale._format_timeframe("days", -12) == "12天"
2099+
assert self.locale._format_timeframe("week", -1) == "1週"
2100+
assert self.locale._format_timeframe("weeks", -38) == "38週"
2101+
assert self.locale._format_timeframe("month", -1) == "1個月"
2102+
assert self.locale._format_timeframe("months", -11) == "11個月"
2103+
assert self.locale._format_timeframe("year", -1) == "1年"
2104+
assert self.locale._format_timeframe("years", -12) == "12年"
2105+
2106+
def test_format_relative_now(self):
2107+
assert self.locale._format_relative("剛才", "now", 0) == "剛才"
2108+
2109+
def test_format_relative_past(self):
2110+
assert self.locale._format_relative("1秒", "second", 1) == "1秒後"
2111+
assert self.locale._format_relative("2秒", "seconds", 2) == "2秒後"
2112+
assert self.locale._format_relative("1分鐘", "minute", 1) == "1分鐘後"
2113+
assert self.locale._format_relative("2分鐘", "minutes", 2) == "2分鐘後"
2114+
assert self.locale._format_relative("1小時", "hour", 1) == "1小時後"
2115+
assert self.locale._format_relative("2小時", "hours", 2) == "2小時後"
2116+
assert self.locale._format_relative("1天", "day", 1) == "1天後"
2117+
assert self.locale._format_relative("2天", "days", 2) == "2天後"
2118+
assert self.locale._format_relative("1週", "week", 1) == "1週後"
2119+
assert self.locale._format_relative("2週", "weeks", 2) == "2週後"
2120+
assert self.locale._format_relative("1個月", "month", 1) == "1個月後"
2121+
assert self.locale._format_relative("2個月", "months", 2) == "2個月後"
2122+
assert self.locale._format_relative("1年", "year", 1) == "1年後"
2123+
assert self.locale._format_relative("2年", "years", 2) == "2年後"
2124+
2125+
def test_format_relative_future(self):
2126+
assert self.locale._format_relative("1秒", "second", -1) == "1秒前"
2127+
assert self.locale._format_relative("2秒", "seconds", -2) == "2秒前"
2128+
assert self.locale._format_relative("1分鐘", "minute", -1) == "1分鐘前"
2129+
assert self.locale._format_relative("2分鐘", "minutes", -2) == "2分鐘前"
2130+
assert self.locale._format_relative("1小時", "hour", -1) == "1小時前"
2131+
assert self.locale._format_relative("2小時", "hours", -2) == "2小時前"
2132+
assert self.locale._format_relative("1天", "day", -1) == "1天前"
2133+
assert self.locale._format_relative("2天", "days", -2) == "2天前"
2134+
assert self.locale._format_relative("1週", "week", -1) == "1週前"
2135+
assert self.locale._format_relative("2週", "weeks", -2) == "2週前"
2136+
assert self.locale._format_relative("1個月", "month", -1) == "1個月前"
2137+
assert self.locale._format_relative("2個月", "months", -2) == "2個月前"
2138+
assert self.locale._format_relative("1年", "year", -1) == "1年前"
2139+
assert self.locale._format_relative("2年", "years", -2) == "2年前"
2140+
20412141

20422142
@pytest.mark.usefixtures("lang_locale")
20432143
class TestChineseCNLocale:
@@ -2058,6 +2158,56 @@ def test_format_timeframe(self):
20582158
assert self.locale._format_timeframe("year", 1) == "1年"
20592159
assert self.locale._format_timeframe("years", 12) == "12年"
20602160

2161+
assert self.locale._format_timeframe("second", -1) == "1秒"
2162+
assert self.locale._format_timeframe("seconds", -30) == "30秒"
2163+
assert self.locale._format_timeframe("minute", -1) == "1分钟"
2164+
assert self.locale._format_timeframe("minutes", -40) == "40分钟"
2165+
assert self.locale._format_timeframe("hour", -1) == "1小时"
2166+
assert self.locale._format_timeframe("hours", -23) == "23小时"
2167+
assert self.locale._format_timeframe("day", -1) == "1天"
2168+
assert self.locale._format_timeframe("days", -12) == "12天"
2169+
assert self.locale._format_timeframe("week", -1) == "1周"
2170+
assert self.locale._format_timeframe("weeks", -38) == "38周"
2171+
assert self.locale._format_timeframe("month", -1) == "1个月"
2172+
assert self.locale._format_timeframe("months", -11) == "11个月"
2173+
assert self.locale._format_timeframe("year", -1) == "1年"
2174+
assert self.locale._format_timeframe("years", -12) == "12年"
2175+
2176+
def test_format_relative_now(self):
2177+
assert self.locale._format_relative("刚才", "now", 0) == "刚才"
2178+
2179+
def test_format_relative_past(self):
2180+
assert self.locale._format_relative("1秒", "second", 1) == "1秒后"
2181+
assert self.locale._format_relative("2秒", "seconds", 2) == "2秒后"
2182+
assert self.locale._format_relative("1分钟", "minute", 1) == "1分钟后"
2183+
assert self.locale._format_relative("2分钟", "minutes", 2) == "2分钟后"
2184+
assert self.locale._format_relative("1小时", "hour", 1) == "1小时后"
2185+
assert self.locale._format_relative("2小时", "hours", 2) == "2小时后"
2186+
assert self.locale._format_relative("1天", "day", 1) == "1天后"
2187+
assert self.locale._format_relative("2天", "days", 2) == "2天后"
2188+
assert self.locale._format_relative("1周", "week", 1) == "1周后"
2189+
assert self.locale._format_relative("2周", "weeks", 2) == "2周后"
2190+
assert self.locale._format_relative("1个月", "month", 1) == "1个月后"
2191+
assert self.locale._format_relative("2个月", "months", 2) == "2个月后"
2192+
assert self.locale._format_relative("1年", "year", 1) == "1年后"
2193+
assert self.locale._format_relative("2年", "years", 2) == "2年后"
2194+
2195+
def test_format_relative_future(self):
2196+
assert self.locale._format_relative("1秒", "second", -1) == "1秒前"
2197+
assert self.locale._format_relative("2秒", "seconds", -2) == "2秒前"
2198+
assert self.locale._format_relative("1分钟", "minute", -1) == "1分钟前"
2199+
assert self.locale._format_relative("2分钟", "minutes", -2) == "2分钟前"
2200+
assert self.locale._format_relative("1小时", "hour", -1) == "1小时前"
2201+
assert self.locale._format_relative("2小时", "hours", -2) == "2小时前"
2202+
assert self.locale._format_relative("1天", "day", -1) == "1天前"
2203+
assert self.locale._format_relative("2天", "days", -2) == "2天前"
2204+
assert self.locale._format_relative("1周", "week", -1) == "1周前"
2205+
assert self.locale._format_relative("2周", "weeks", -2) == "2周前"
2206+
assert self.locale._format_relative("1个月", "month", -1) == "1个月前"
2207+
assert self.locale._format_relative("2个月", "months", -2) == "2个月前"
2208+
assert self.locale._format_relative("1年", "year", -1) == "1年前"
2209+
assert self.locale._format_relative("2年", "years", -2) == "2年前"
2210+
20612211

20622212
@pytest.mark.usefixtures("lang_locale")
20632213
class TestSwahiliLocale:

0 commit comments

Comments
 (0)