Show More
@@ -554,7 +554,14 b' def _set_pprinter_factory(start, end, basetype):' | |||||
554 | else: |
|
554 | else: | |
555 | step = len(start) |
|
555 | step = len(start) | |
556 | p.begin_group(step, start) |
|
556 | p.begin_group(step, start) | |
557 | for idx, x in enumerate(obj): |
|
557 | # Like dictionary keys, we will try to sort the items. | |
|
558 | items = list(obj) | |||
|
559 | try: | |||
|
560 | items.sort() | |||
|
561 | except Exception: | |||
|
562 | # Sometimes the items don't sort. | |||
|
563 | pass | |||
|
564 | for idx, x in enumerate(items): | |||
558 | if idx: |
|
565 | if idx: | |
559 | p.text(',') |
|
566 | p.text(',') | |
560 | p.breakable() |
|
567 | p.breakable() |
@@ -89,10 +89,10 b' def test_sets():' | |||||
89 | """ |
|
89 | """ | |
90 | Test that set and frozenset use Python 3 formatting. |
|
90 | Test that set and frozenset use Python 3 formatting. | |
91 | """ |
|
91 | """ | |
92 | objects = [set(), frozenset(), set([1]), frozenset([1]), set([1,2]), |
|
92 | objects = [set(), frozenset(), set([1]), frozenset([1]), set([1, 2]), | |
93 | frozenset([1,2])] |
|
93 | frozenset([1, 2]), set([-1, -2, -3])] | |
94 | expected = ['set()', 'frozenset()', '{1}', 'frozenset({1})', '{1, 2}', |
|
94 | expected = ['set()', 'frozenset()', '{1}', 'frozenset({1})', '{1, 2}', | |
95 | 'frozenset({1, 2})'] |
|
95 | 'frozenset({1, 2})', '{-3, -2, -1}'] | |
96 | for obj, expected_output in zip(objects, expected): |
|
96 | for obj, expected_output in zip(objects, expected): | |
97 | got_output = pretty.pretty(obj) |
|
97 | got_output = pretty.pretty(obj) | |
98 | yield nt.assert_equal, got_output, expected_output |
|
98 | yield nt.assert_equal, got_output, expected_output |
General Comments 0
You need to be logged in to leave comments.
Login now