changeset 0de649015597 in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset&node=0de649015597
description:
Move test of tools under tools test case
diffstat:
trytond/tests/test_tools.py | 84 ++++++++++++++++++++++----------------------
1 files changed, 42 insertions(+), 42 deletions(-)
diffs (101 lines):
diff -r 2d11879d7a3b -r 0de649015597 trytond/tests/test_tools.py
--- a/trytond/tests/test_tools.py Thu Oct 21 00:11:57 2021 +0200
+++ b/trytond/tests/test_tools.py Tue Oct 26 00:22:23 2021 +0200
@@ -229,6 +229,48 @@
"Test hyphenate in slugify"
self.assertEqual(slugify('foo bar', hyphenate='_'), 'foo_bar')
+ def test_sortable_values(self):
+ def key(values):
+ return values
+
+ values = [
+ (('a', 1), ('b', None)),
+ (('a', 1), ('b', 3)),
+ (('a', 1), ('b', 2)),
+ ]
+
+ with self.assertRaises(TypeError):
+ sorted(values, key=key)
+ self.assertEqual(
+ sorted(values, key=sortable_values(key)), [
+ (('a', 1), ('b', 2)),
+ (('a', 1), ('b', 3)),
+ (('a', 1), ('b', None)),
+ ])
+
+ def test_firstline(self):
+ "Test firstline"
+ for text, result in [
+ ("", ""),
+ ("first line\nsecond line", "first line"),
+ ("\nsecond line", "second line"),
+ ("\n\nthird line", "third line"),
+ (" \nsecond line", "second line"),
+ ]:
+ with self.subTest(text=text, result=result):
+ self.assertEqual(firstline(text), result)
+
+ def test_remove_forbidden_chars(self):
+ "Test remove_forbidden_chars"
+ for string, result in [
+ ("", ""),
+ (None, None),
+ ("\ttest", "test"),
+ (" test ", "test"),
+ ]:
+ with self.subTest(string=string):
+ self.assertEqual(remove_forbidden_chars(string), result)
+
class StringPartitionedTestCase(unittest.TestCase):
"Test StringPartitioned"
@@ -879,48 +921,6 @@
extract_reference_models(domain, 'x'), {'model_A', 'model_B'})
self.assertEqual(extract_reference_models(domain, 'y'), set())
- def test_sortable_values(self):
- def key(values):
- return values
-
- values = [
- (('a', 1), ('b', None)),
- (('a', 1), ('b', 3)),
- (('a', 1), ('b', 2)),
- ]
-
- with self.assertRaises(TypeError):
- sorted(values, key=key)
- self.assertEqual(
- sorted(values, key=sortable_values(key)), [
- (('a', 1), ('b', 2)),
- (('a', 1), ('b', 3)),
- (('a', 1), ('b', None)),
- ])
-
- def test_firstline(self):
- "Test firstline"
- for text, result in [
- ("", ""),
- ("first line\nsecond line", "first line"),
- ("\nsecond line", "second line"),
- ("\n\nthird line", "third line"),
- (" \nsecond line", "second line"),
- ]:
- with self.subTest(text=text, result=result):
- self.assertEqual(firstline(text), result)
-
- def test_remove_forbidden_chars(self):
- "Test remove_forbidden_chars"
- for string, result in [
- ("", ""),
- (None, None),
- ("\ttest", "test"),
- (" test ", "test"),
- ]:
- with self.subTest(string=string):
- self.assertEqual(remove_forbidden_chars(string), result)
-
def suite():
func = unittest.TestLoader().loadTestsFromTestCase