summaryrefslogtreecommitdiff
path: root/urwid/tests/test_util.py
diff options
context:
space:
mode:
Diffstat (limited to 'urwid/tests/test_util.py')
-rw-r--r--urwid/tests/test_util.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/urwid/tests/test_util.py b/urwid/tests/test_util.py
index 5f0531d..7e0acdb 100644
--- a/urwid/tests/test_util.py
+++ b/urwid/tests/test_util.py
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
import unittest
+import locale
import urwid
from urwid import util
@@ -176,3 +177,35 @@ class TagMarkupTest(unittest.TestCase):
def test_bad_type(self):
self.assertRaises(urwid.TagMarkupException, lambda:
urwid.decompose_tagmarkup(5))
+
+class RleTest(unittest.TestCase):
+ def test_rle_prepend(self):
+ rle0 = [('A', 10), ('B', 15)]
+ # the rle functions are mutating, so make a few copies of rle0
+ rle1, rle2 = rle0[:], rle0[:]
+ util.rle_prepend_modify(rle1, ('A', 3))
+ util.rle_prepend_modify(rle2, ('X', 2))
+ self.assertListEqual(rle1, [('A', 13), ('B', 15)])
+ self.assertListEqual(rle2, [('X', 2), ('A', 10), ('B', 15)])
+
+ def test_rle_append(self):
+ rle0 = [('A', 10), ('B', 15)]
+ rle3, rle4 = rle0[:], rle0[:]
+ util.rle_append_modify(rle3, ('B', 5))
+ util.rle_append_modify(rle4, ('K', 1))
+ self.assertListEqual(rle3, [('A', 10), ('B', 20)])
+ self.assertListEqual(rle4, [('A', 10), ('B', 15), ('K', 1)])
+
+class PortabilityTest(unittest.TestCase):
+ def test_locale(self):
+ initial = locale.getlocale()
+
+ locale.setlocale(locale.LC_ALL, (None, None))
+ util.detect_encoding()
+ self.assertEqual(locale.getlocale(), (None, None))
+
+ locale.setlocale(locale.LC_ALL, ('en_US', 'UTF-8'))
+ util.detect_encoding()
+ self.assertEqual(locale.getlocale(), ('en_US', 'UTF-8'))
+
+ locale.setlocale(locale.LC_ALL, initial)