MCPcopy
hub / github.com/django/django / test_smart_split

Method test_smart_split

tests/utils_tests/test_text.py:25–58  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

23 self.assertEqual(text.get_text_list(["a", "b", "c"]), "a، b أو c")
24
25 def test_smart_split(self):
26 testdata = [
27 ('This is "a person" test.', ["This", "is", '"a person"', "test."]),
28 ('This is "a person\'s" test.', ["This", "is", '"a person\'s"', "test."]),
29 ('This is "a person\\"s" test.', ["This", "is", '"a person\\"s"', "test."]),
30 ("\"a 'one", ['"a', "'one"]),
31 ("all friends' tests", ["all", "friends'", "tests"]),
32 (
33 'url search_page words="something else"',
34 ["url", "search_page", 'words="something else"'],
35 ),
36 (
37 "url search_page words='something else'",
38 ["url", "search_page", "words='something else'"],
39 ),
40 (
41 'url search_page words "something else"',
42 ["url", "search_page", "words", '"something else"'],
43 ),
44 (
45 'url search_page words-"something else"',
46 ["url", "search_page", 'words-"something else"'],
47 ),
48 ("url search_page words=hello", ["url", "search_page", "words=hello"]),
49 (
50 'url search_page words="something else',
51 ["url", "search_page", 'words="something', "else"],
52 ),
53 ("cut:','|cut:' '", ["cut:','|cut:' '"]),
54 (lazystr("a b c d"), ["a", "b", "c", "d"]), # Test for #20231
55 ]
56 for test, expected in testdata:
57 with self.subTest(value=test):
58 self.assertEqual(list(text.smart_split(test)), expected)
59
60 def test_truncate_chars(self):
61 truncator = text.Truncator("The quick brown fox jumped over the lazy dog.")

Callers

nothing calls this directly

Calls 1

lazystrFunction · 0.90

Tested by

no test coverage detected