Commit eaea4aa3 authored by Greg Ward's avatar Greg Ward

Simplify and reformat the use of 'subcases' lists (and following

for-loops) in test_simple(), test_wrap_short() test_hyphenated(), and
test_funky_punc().
parent 7735d70f
...@@ -45,25 +45,19 @@ class WrapTestCase(WrapperTestCase): ...@@ -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?",
] ), "I'm glad to hear it!"]),
( (t, 42), [ (80, [t]),
"Hello there, how are you this fine day?",
"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! ...@@ -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! ...@@ -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?" ...@@ -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?"',
] ), 'How *do* you spell that odd word, anyways?']),
( (t, 50), [
'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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment