diff options
author | Raymond Hettinger <python@rcn.com> | 2004-05-21 10:00:15 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2004-05-21 10:00:15 (GMT) |
commit | ba6cd3647ff5bd0415dcdb4649a5e6a7a88c0e72 (patch) | |
tree | 8355d4adb9d4c4a618d7894c6155dbce88ef4fce /Lib/test/test_repr.py | |
parent | 83ee79524ae6462b7b044bb9cf2f625231814dba (diff) | |
download | cpython-ba6cd3647ff5bd0415dcdb4649a5e6a7a88c0e72.zip cpython-ba6cd3647ff5bd0415dcdb4649a5e6a7a88c0e72.tar.gz cpython-ba6cd3647ff5bd0415dcdb4649a5e6a7a88c0e72.tar.bz2 |
* Updated repr.py to handle set() and frozenset().
* Factored out common code to a single private function.
* Use str.join() instead of + concatenation
* Loop over elements directly instead of using indexing
* Use % operator for formatting
Diffstat (limited to 'Lib/test/test_repr.py')
-rw-r--r-- | Lib/test/test_repr.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_repr.py b/Lib/test/test_repr.py index 48d969f..b00f328 100644 --- a/Lib/test/test_repr.py +++ b/Lib/test/test_repr.py @@ -51,6 +51,20 @@ class ReprTests(unittest.TestCase): eq(r([1, 2, 3, 4, 5, 6]), "[1, 2, 3, 4, 5, 6]") eq(r([1, 2, 3, 4, 5, 6, 7]), "[1, 2, 3, 4, 5, 6, ...]") + # Sets give up after 6 as well + eq(r(set([])), "set([])") + eq(r(set([1])), "set([1])") + eq(r(set([1, 2, 3])), "set([1, 2, 3])") + eq(r(set([1, 2, 3, 4, 5, 6])), "set([1, 2, 3, 4, 5, 6])") + eq(r(set([1, 2, 3, 4, 5, 6, 7])), "set([1, 2, 3, 4, 5, 6, ...])") + + # Frozensets give up after 6 as well + eq(r(frozenset([])), "frozenset([])") + eq(r(frozenset([1])), "frozenset([1])") + eq(r(frozenset([1, 2, 3])), "frozenset([1, 2, 3])") + eq(r(frozenset([1, 2, 3, 4, 5, 6])), "frozenset([1, 2, 3, 4, 5, 6])") + eq(r(frozenset([1, 2, 3, 4, 5, 6, 7])), "frozenset([1, 2, 3, 4, 5, 6, ...])") + # Dictionaries give up after 4. eq(r({}), "{}") d = {'alice': 1, 'bob': 2, 'charles': 3, 'dave': 4} |