From 9ebba9ace31ce0027d8f487a853bda7c2e1661cc Mon Sep 17 00:00:00 2001 From: Greg Ward Date: Thu, 22 Aug 2002 18:45:02 +0000 Subject: [PATCH] Simplify and reformat the use of 'subcases' lists (and following for-loops) in test_simple(), test_wrap_short() test_hyphenated(), and test_funky_punc(). --- Lib/test/test_textwrap.py | 84 +++++++++++++++------------------------ 1 file changed, 32 insertions(+), 52 deletions(-) diff --git a/Lib/test/test_textwrap.py b/Lib/test/test_textwrap.py index f36213ccc0d..cb63387bb04 100644 --- a/Lib/test/test_textwrap.py +++ b/Lib/test/test_textwrap.py @@ -45,25 +45,19 @@ class WrapTestCase(WrapperTestCase): t = "Hello there, how are you this fine day? I'm glad to hear it!" subcases = [ - ( (t, 12), [ - "Hello there,", - "how are you", - "this fine", - "day? I'm", - "glad to hear", - "it!" - ] ), - ( (t, 42), [ - "Hello there, how are you this fine day?", - "I'm glad to hear it!" - ] ), - ( (t, 80), [ - t - ] ), + (12, ["Hello there,", + "how are you", + "this fine", + "day? I'm", + "glad to hear", + "it!"]), + (42, ["Hello there, how are you this fine day?", + "I'm glad to hear it!"]), + (80, [t]), ] - for test, expect in subcases: - result = wrap(*test) + for width, expect in subcases: + result = wrap(t, width) self.check(result, expect) @@ -99,17 +93,13 @@ What a mess! t = "This is a\nshort paragraph." subcases = [ - ( (t, 20), [ - "This is a short", - "paragraph." - ] ), - ( (t, 40), [ - "This is a short paragraph." - ] ), + (20, ["This is a short", + "paragraph."]), + (40, ["This is a short paragraph."]), ] - for test, expect in subcases: - result = wrap(*test) + for width, expect in subcases: + result = wrap(t, width) self.check(result, expect) @@ -119,22 +109,16 @@ What a mess! t = "this-is-a-useful-feature-for-reformatting-posts-from-tim-peters'ly" subcases = [ - ( (t, 40), [ - "this-is-a-useful-feature-for-", - "reformatting-posts-from-tim-peters'ly" - ] ), - ( (t, 41), [ - "this-is-a-useful-feature-for-", - "reformatting-posts-from-tim-peters'ly" - ] ), - ( (t, 42), [ - "this-is-a-useful-feature-for-reformatting-", - "posts-from-tim-peters'ly" - ] ), + (40, ["this-is-a-useful-feature-for-", + "reformatting-posts-from-tim-peters'ly"]), + (41, ["this-is-a-useful-feature-for-", + "reformatting-posts-from-tim-peters'ly"]), + (42, ["this-is-a-useful-feature-for-reformatting-", + "posts-from-tim-peters'ly"]), ] - for test, expect in subcases: - result = wrap(*test) + for width, expect in subcases: + result = wrap(t, width) self.check(result, expect) @@ -158,20 +142,16 @@ Did you say "supercalifragilisticexpialidocious?" How *do* you spell that odd word, anyways? ''' subcases = [ - ( (t, 30), [ - 'Did you say "supercalifragilis', - 'ticexpialidocious?" How *do*', - 'you spell that odd word,', - 'anyways?' - ] ), - ( (t, 50), [ - 'Did you say "supercalifragilisticexpialidocious?"', - 'How *do* you spell that odd word, anyways?' - ] ), + (30, ['Did you say "supercalifragilis', + 'ticexpialidocious?" How *do*', + 'you spell that odd word,', + 'anyways?']), + (50, ['Did you say "supercalifragilisticexpialidocious?"', + 'How *do* you spell that odd word, anyways?']), ] - for test, expect in subcases: - result = wrap(*test) + for width, expect in subcases: + result = wrap(t, width) self.check(result, expect)