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
f3fa3088
Commit
f3fa3088
authored
Mar 26, 2015
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #23776: Removed asserts from pprint.PrettyPrinter constructor.
parent
e6bb7eb2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
7 deletions
+23
-7
Lib/pprint.py
Lib/pprint.py
+6
-3
Lib/test/test_pprint.py
Lib/test/test_pprint.py
+17
-4
No files found.
Lib/pprint.py
View file @
f3fa3088
...
...
@@ -124,9 +124,12 @@ class PrettyPrinter:
"""
indent
=
int
(
indent
)
width
=
int
(
width
)
assert
indent
>=
0
,
"indent must be >= 0"
assert
depth
is
None
or
depth
>
0
,
"depth must be > 0"
assert
width
,
"width must be != 0"
if
indent
<
0
:
raise
ValueError
(
'indent must be >= 0'
)
if
depth
is
not
None
and
depth
<=
0
:
raise
ValueError
(
'depth must be > 0'
)
if
not
width
:
raise
ValueError
(
'width must be != 0'
)
self
.
_depth
=
depth
self
.
_indent_per_level
=
indent
self
.
_width
=
width
...
...
Lib/test/test_pprint.py
View file @
f3fa3088
# -*- coding: utf-8 -*-
import
collections
import
io
import
itertools
import
pprint
import
random
import
test.support
import
unittest
import
test.test_set
import
random
import
collections
import
itertools
import
types
import
unittest
# list, tuple and dict subclasses that do or don't overwrite __repr__
class
list2
(
list
):
...
...
@@ -56,6 +57,18 @@ class QueryTestCase(unittest.TestCase):
self
.
b
=
list
(
range
(
200
))
self
.
a
[
-
12
]
=
self
.
b
def
test_init
(
self
):
pp
=
pprint
.
PrettyPrinter
()
pp
=
pprint
.
PrettyPrinter
(
indent
=
4
,
width
=
40
,
depth
=
5
,
stream
=
io
.
StringIO
(),
compact
=
True
)
pp
=
pprint
.
PrettyPrinter
(
4
,
40
,
5
,
io
.
StringIO
())
with
self
.
assertRaises
(
TypeError
):
pp
=
pprint
.
PrettyPrinter
(
4
,
40
,
5
,
io
.
StringIO
(),
True
)
self
.
assertRaises
(
ValueError
,
pprint
.
PrettyPrinter
,
indent
=-
1
)
self
.
assertRaises
(
ValueError
,
pprint
.
PrettyPrinter
,
depth
=
0
)
self
.
assertRaises
(
ValueError
,
pprint
.
PrettyPrinter
,
depth
=-
1
)
self
.
assertRaises
(
ValueError
,
pprint
.
PrettyPrinter
,
width
=
0
)
def
test_basic
(
self
):
# Verify .isrecursive() and .isreadable() w/o recursion
pp
=
pprint
.
PrettyPrinter
()
...
...
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