summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAarni Koskela <akx@iki.fi>2019-05-27 11:19:08 +0300
committerAarni Koskela <akx@iki.fi>2019-05-27 11:37:12 +0300
commit1d7a4da9e1a563e800dc6475bc95e1fa58a07473 (patch)
treee3ed63a3a3524727f33265cf4dd8cfea84f227cb /tests
parent4fa0c6e5a2d3ae4c10ca160dabe4e3d169dace81 (diff)
downloadbabel-1d7a4da9e1a563e800dc6475bc95e1fa58a07473.tar.gz
Add comparison operators to _NormalizedString
Based on @hoangduytranuk's original implementation. Fixes #612
Diffstat (limited to 'tests')
-rw-r--r--tests/messages/test_normalized_string.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/messages/test_normalized_string.py b/tests/messages/test_normalized_string.py
new file mode 100644
index 0000000..9c95672
--- /dev/null
+++ b/tests/messages/test_normalized_string.py
@@ -0,0 +1,17 @@
+from babel.messages.pofile import _NormalizedString
+
+
+def test_normalized_string():
+ ab1 = _NormalizedString('a', 'b ')
+ ab2 = _NormalizedString('a', ' b')
+ ac1 = _NormalizedString('a', 'c')
+ ac2 = _NormalizedString(' a', 'c ')
+ z = _NormalizedString()
+ assert ab1 == ab2 and ac1 == ac2 # __eq__
+ assert ab1 < ac1 # __lt__
+ assert ac1 > ab2 # __gt__
+ assert ac1 >= ac2 # __ge__
+ assert ab1 <= ab2 # __le__
+ assert ab1 != ac1 # __ne__
+ assert not z # __nonzero__ / __bool__
+ assert sorted([ab1, ab2, ac1]) # the sort order is not stable so we can't really check it, just that we can sort