mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
Simplify and reformat the use of 'subcases' lists (and following
for-loops) in test_simple(), test_wrap_short() test_hyphenated(), and test_funky_punc().
This commit is contained in:
parent
3dc94e14c0
commit
9ebba9ace3
1 changed files with 32 additions and 52 deletions
|
@ -45,25 +45,19 @@ class WrapTestCase(WrapperTestCase):
|
||||||
t = "Hello there, how are you this fine day? I'm glad to hear it!"
|
t = "Hello there, how are you this fine day? I'm glad to hear it!"
|
||||||
|
|
||||||
subcases = [
|
subcases = [
|
||||||
( (t, 12), [
|
(12, ["Hello there,",
|
||||||
"Hello there,",
|
|
||||||
"how are you",
|
"how are you",
|
||||||
"this fine",
|
"this fine",
|
||||||
"day? I'm",
|
"day? I'm",
|
||||||
"glad to hear",
|
"glad to hear",
|
||||||
"it!"
|
"it!"]),
|
||||||
] ),
|
(42, ["Hello there, how are you this fine day?",
|
||||||
( (t, 42), [
|
"I'm glad to hear it!"]),
|
||||||
"Hello there, how are you this fine day?",
|
(80, [t]),
|
||||||
"I'm glad to hear it!"
|
|
||||||
] ),
|
|
||||||
( (t, 80), [
|
|
||||||
t
|
|
||||||
] ),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
for test, expect in subcases:
|
for width, expect in subcases:
|
||||||
result = wrap(*test)
|
result = wrap(t, width)
|
||||||
self.check(result, expect)
|
self.check(result, expect)
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,17 +93,13 @@ What a mess!
|
||||||
t = "This is a\nshort paragraph."
|
t = "This is a\nshort paragraph."
|
||||||
|
|
||||||
subcases = [
|
subcases = [
|
||||||
( (t, 20), [
|
(20, ["This is a short",
|
||||||
"This is a short",
|
"paragraph."]),
|
||||||
"paragraph."
|
(40, ["This is a short paragraph."]),
|
||||||
] ),
|
|
||||||
( (t, 40), [
|
|
||||||
"This is a short paragraph."
|
|
||||||
] ),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
for test, expect in subcases:
|
for width, expect in subcases:
|
||||||
result = wrap(*test)
|
result = wrap(t, width)
|
||||||
self.check(result, expect)
|
self.check(result, expect)
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,22 +109,16 @@ What a mess!
|
||||||
t = "this-is-a-useful-feature-for-reformatting-posts-from-tim-peters'ly"
|
t = "this-is-a-useful-feature-for-reformatting-posts-from-tim-peters'ly"
|
||||||
|
|
||||||
subcases = [
|
subcases = [
|
||||||
( (t, 40), [
|
(40, ["this-is-a-useful-feature-for-",
|
||||||
"this-is-a-useful-feature-for-",
|
"reformatting-posts-from-tim-peters'ly"]),
|
||||||
"reformatting-posts-from-tim-peters'ly"
|
(41, ["this-is-a-useful-feature-for-",
|
||||||
] ),
|
"reformatting-posts-from-tim-peters'ly"]),
|
||||||
( (t, 41), [
|
(42, ["this-is-a-useful-feature-for-reformatting-",
|
||||||
"this-is-a-useful-feature-for-",
|
"posts-from-tim-peters'ly"]),
|
||||||
"reformatting-posts-from-tim-peters'ly"
|
|
||||||
] ),
|
|
||||||
( (t, 42), [
|
|
||||||
"this-is-a-useful-feature-for-reformatting-",
|
|
||||||
"posts-from-tim-peters'ly"
|
|
||||||
] ),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
for test, expect in subcases:
|
for width, expect in subcases:
|
||||||
result = wrap(*test)
|
result = wrap(t, width)
|
||||||
self.check(result, expect)
|
self.check(result, expect)
|
||||||
|
|
||||||
|
|
||||||
|
@ -158,20 +142,16 @@ Did you say "supercalifragilisticexpialidocious?"
|
||||||
How *do* you spell that odd word, anyways?
|
How *do* you spell that odd word, anyways?
|
||||||
'''
|
'''
|
||||||
subcases = [
|
subcases = [
|
||||||
( (t, 30), [
|
(30, ['Did you say "supercalifragilis',
|
||||||
'Did you say "supercalifragilis',
|
|
||||||
'ticexpialidocious?" How *do*',
|
'ticexpialidocious?" How *do*',
|
||||||
'you spell that odd word,',
|
'you spell that odd word,',
|
||||||
'anyways?'
|
'anyways?']),
|
||||||
] ),
|
(50, ['Did you say "supercalifragilisticexpialidocious?"',
|
||||||
( (t, 50), [
|
'How *do* you spell that odd word, anyways?']),
|
||||||
'Did you say "supercalifragilisticexpialidocious?"',
|
|
||||||
'How *do* you spell that odd word, anyways?'
|
|
||||||
] ),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
for test, expect in subcases:
|
for width, expect in subcases:
|
||||||
result = wrap(*test)
|
result = wrap(t, width)
|
||||||
self.check(result, expect)
|
self.check(result, expect)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue