Skip to content

Commit

Permalink
Added test for _userlist_pprint
Browse files Browse the repository at this point in the history
 - all tests passed
  • Loading branch information
007vedant authored and Carreau committed Dec 1, 2021
1 parent b48dbbb commit aca50d2
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion IPython/lib/tests/test_pretty.py
Expand Up @@ -5,7 +5,7 @@
# Distributed under the terms of the Modified BSD License.


from collections import Counter, defaultdict, deque, OrderedDict
from collections import Counter, defaultdict, deque, OrderedDict, UserList
import os
import pytest
import types
Expand Down Expand Up @@ -294,6 +294,42 @@ def type_pprint_wrapper(obj, p, cycle):
assert type_pprint_wrapper.called is True


def test_collections_userlist():
# Create userlist with cycle
a = UserList()
a.append(a)

cases = [
(UserList(), "UserList([])"),
(
UserList(i for i in range(1000, 1020)),
"UserList([1000,\n"
" 1001,\n"
" 1002,\n"
" 1003,\n"
" 1004,\n"
" 1005,\n"
" 1006,\n"
" 1007,\n"
" 1008,\n"
" 1009,\n"
" 1010,\n"
" 1011,\n"
" 1012,\n"
" 1013,\n"
" 1014,\n"
" 1015,\n"
" 1016,\n"
" 1017,\n"
" 1018,\n"
" 1019])",
),
(a, "UserList([UserList(...)])"),
]
for obj, expected in cases:
assert pretty.pretty(obj) == expected


# TODO : pytest.mark.parametrise once nose is gone.
def test_collections_defaultdict():
# Create defaultdicts with cycles
Expand Down

0 comments on commit aca50d2

Please sign in to comment.