Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
715debd3
Commit
715debd3
authored
Aug 22, 2002
by
Greg Ward
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factored out BaseTestCase.check_split() method -- use it wherever
we need to test TextWrapper._split().
parent
24a1c9cf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
Lib/test/test_textwrap.py
Lib/test/test_textwrap.py
+8
-8
No files found.
Lib/test/test_textwrap.py
View file @
715debd3
...
...
@@ -37,6 +37,12 @@ class BaseTestCase(unittest.TestCase):
result
=
wrap
(
text
,
width
)
self
.
check
(
result
,
expect
)
def
check_split
(
self
,
wrapper
,
text
,
expect
):
result
=
wrapper
.
_split
(
text
)
self
.
assertEquals
(
result
,
expect
,
"
\
n
expected %r
\
n
"
"but got %r"
%
(
expect
,
result
))
class
WrapTestCase
(
BaseTestCase
):
...
...
@@ -155,13 +161,10 @@ What a mess!
# All of the above behaviour could be deduced by probing the
# _split() method.
text
=
"Here's an -- em-dash and--here's another---and another!"
result
=
self
.
wrapper
.
_split
(
text
)
expect
=
[
"Here's"
,
" "
,
"an"
,
" "
,
"--"
,
" "
,
"em-"
,
"dash"
,
" "
,
"and"
,
"--"
,
"here's"
,
" "
,
"another"
,
"---"
,
"and"
,
" "
,
"another!"
]
self
.
assertEquals
(
result
,
expect
,
"
\
n
expected %r
\
n
"
"but got %r"
%
(
expect
,
result
))
self
.
check_split
(
self
.
wrapper
,
text
,
expect
)
def
test_unix_options
(
self
):
# Test that Unix-style command-line options are wrapped correctly.
...
...
@@ -193,12 +196,9 @@ What a mess!
# Again, all of the above can be deduced from _split().
text
=
"the -n option, or --dry-run or --dryrun"
result
=
self
.
wrapper
.
_split
(
text
)
expect
=
[
"the"
,
" "
,
"-n"
,
" "
,
"option,"
,
" "
,
"or"
,
" "
,
"--dry-"
,
"run"
,
" "
,
"or"
,
" "
,
"--dryrun"
]
self
.
assertEquals
(
result
,
expect
,
"
\
n
expected %r
\
n
"
"but got %r"
%
(
expect
,
result
))
self
.
check_split
(
self
.
wrapper
,
text
,
expect
)
def
test_split
(
self
):
# Ensure that the standard _split() method works as advertised
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment