Fix place ordinal calculation (#1067)

* Fix scoreboard place ordinalization in Python 3
* Extract ordinalization code to `CTFd.utils.humanize.numbers.ordinalize`.
This commit is contained in:
Kevin Chung
2019-07-24 01:44:20 -04:00
committed by GitHub
parent f2e0b9e8b5
commit 2bdf7b64d6
4 changed files with 34 additions and 11 deletions

View File

@@ -0,0 +1,19 @@
from CTFd.utils.humanize.numbers import ordinalize
def test_ordinalize():
tests = {
1: "1st",
2: "2nd",
3: "3rd",
4: "4th",
11: "11th",
12: "12th",
13: "13th",
101: "101st",
102: "102nd",
103: "103rd",
111: "111th",
}
for t, v in tests.items():
assert ordinalize(t) == v