Show More
@@ -117,7 +117,7 class DocTestFinder(doctest.DocTestFinder): | |||
|
117 | 117 | elif isinstance(object, property): |
|
118 | 118 | return True # [XX] no way not be sure. |
|
119 | 119 | else: |
|
120 | raise ValueError("object must be a class or function") | |
|
120 | raise ValueError("object must be a class or function, got %r" % object) | |
|
121 | 121 | |
|
122 | 122 | def _find(self, tests, obj, name, module, source_lines, globs, seen): |
|
123 | 123 | """ |
@@ -40,7 +40,7 def extract_vars(*names,**kw): | |||
|
40 | 40 | |
|
41 | 41 | In [2]: def func(x): |
|
42 | 42 | ...: y = 1 |
|
43 |
...: print |
|
|
43 | ...: print(sorted(extract_vars('x','y').items())) | |
|
44 | 44 | ...: |
|
45 | 45 | |
|
46 | 46 | In [3]: func('hello') |
@@ -173,7 +173,7 def json_clean(obj): | |||
|
173 | 173 | -------- |
|
174 | 174 | >>> json_clean(4) |
|
175 | 175 | 4 |
|
176 | >>> json_clean(range(10)) | |
|
176 | >>> json_clean(list(range(10))) | |
|
177 | 177 | [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] |
|
178 | 178 | >>> sorted(json_clean(dict(x=1, y=2)).items()) |
|
179 | 179 | [('x', 1), ('y', 2)] |
@@ -93,8 +93,8 if sys.version_info[0] >= 3: | |||
|
93 | 93 | |
|
94 | 94 | open = orig_open |
|
95 | 95 | xrange = range |
|
96 |
iteritems |
|
|
97 |
itervalues |
|
|
96 | def iteritems(d): return iter(d.items()) | |
|
97 | def itervalues(d): return iter(d.values()) | |
|
98 | 98 | |
|
99 | 99 | MethodType = types.MethodType |
|
100 | 100 | |
@@ -170,8 +170,8 else: | |||
|
170 | 170 | self.f.close() |
|
171 | 171 | |
|
172 | 172 | xrange = xrange |
|
173 |
iteritems |
|
|
174 |
itervalues |
|
|
173 | def iteritems(d): return d.iteritems() | |
|
174 | def itervalues(d): return d.itervalues() | |
|
175 | 175 | |
|
176 | 176 | def MethodType(func, instance): |
|
177 | 177 | return types.MethodType(func, instance, type(instance)) |
@@ -116,7 +116,7 def teardown_environment(): | |||
|
116 | 116 | os.chdir(old_wd) |
|
117 | 117 | reload(path) |
|
118 | 118 | |
|
119 |
for key in env |
|
|
119 | for key in list(env): | |
|
120 | 120 | if key not in oldenv: |
|
121 | 121 | del env[key] |
|
122 | 122 | env.update(oldenv) |
@@ -505,8 +505,8 class TestShellGlob(object): | |||
|
505 | 505 | |
|
506 | 506 | @classmethod |
|
507 | 507 | def setUpClass(cls): |
|
508 |
cls.filenames_start_with_a = |
|
|
509 |
cls.filenames_end_with_b = |
|
|
508 | cls.filenames_start_with_a = ['a0', 'a1', 'a2'] | |
|
509 | cls.filenames_end_with_b = ['0b', '1b', '2b'] | |
|
510 | 510 | cls.filenames = cls.filenames_start_with_a + cls.filenames_end_with_b |
|
511 | 511 | cls.tempdir = TemporaryDirectory() |
|
512 | 512 | td = cls.tempdir.name |
@@ -148,16 +148,16 class TestTraitType(TestCase): | |||
|
148 | 148 | |
|
149 | 149 | a = A() |
|
150 | 150 | self.assertEqual(a._trait_values, {}) |
|
151 | self.assertEqual(a._trait_dyn_inits.keys(), ['x']) | |
|
151 | self.assertEqual(list(a._trait_dyn_inits.keys()), ['x']) | |
|
152 | 152 | self.assertEqual(a.x, 11) |
|
153 | 153 | self.assertEqual(a._trait_values, {'x': 11}) |
|
154 | 154 | b = B() |
|
155 | 155 | self.assertEqual(b._trait_values, {'x': 20}) |
|
156 | self.assertEqual(a._trait_dyn_inits.keys(), ['x']) | |
|
156 | self.assertEqual(list(a._trait_dyn_inits.keys()), ['x']) | |
|
157 | 157 | self.assertEqual(b.x, 20) |
|
158 | 158 | c = C() |
|
159 | 159 | self.assertEqual(c._trait_values, {}) |
|
160 | self.assertEqual(a._trait_dyn_inits.keys(), ['x']) | |
|
160 | self.assertEqual(list(a._trait_dyn_inits.keys()), ['x']) | |
|
161 | 161 | self.assertEqual(c.x, 21) |
|
162 | 162 | self.assertEqual(c._trait_values, {'x': 21}) |
|
163 | 163 | # Ensure that the base class remains unmolested when the _default |
@@ -165,7 +165,7 class TestTraitType(TestCase): | |||
|
165 | 165 | a = A() |
|
166 | 166 | c = C() |
|
167 | 167 | self.assertEqual(a._trait_values, {}) |
|
168 | self.assertEqual(a._trait_dyn_inits.keys(), ['x']) | |
|
168 | self.assertEqual(list(a._trait_dyn_inits.keys()), ['x']) | |
|
169 | 169 | self.assertEqual(a.x, 11) |
|
170 | 170 | self.assertEqual(a._trait_values, {'x': 11}) |
|
171 | 171 | |
@@ -886,7 +886,7 class TestList(TraitTestBase): | |||
|
886 | 886 | obj = ListTrait() |
|
887 | 887 | |
|
888 | 888 | _default_value = [] |
|
889 | _good_values = [[], [1], range(10)] | |
|
889 | _good_values = [[], [1], list(range(10))] | |
|
890 | 890 | _bad_values = [10, [1,'a'], 'a', (1,2)] |
|
891 | 891 | |
|
892 | 892 | class LenListTrait(HasTraits): |
@@ -898,8 +898,8 class TestLenList(TraitTestBase): | |||
|
898 | 898 | obj = LenListTrait() |
|
899 | 899 | |
|
900 | 900 | _default_value = [0] |
|
901 | _good_values = [[1], range(2)] | |
|
902 | _bad_values = [10, [1,'a'], 'a', (1,2), [], range(3)] | |
|
901 | _good_values = [[1], list(range(2))] | |
|
902 | _bad_values = [10, [1,'a'], 'a', (1,2), [], list(range(3))] | |
|
903 | 903 | |
|
904 | 904 | class TupleTrait(HasTraits): |
|
905 | 905 |
@@ -621,7 +621,7 def _chunks(l, n): | |||
|
621 | 621 | def _find_optimal(rlist , separator_size=2 , displaywidth=80): |
|
622 | 622 | """Calculate optimal info to columnize a list of string""" |
|
623 | 623 | for nrow in range(1, len(rlist)+1) : |
|
624 | chk = map(max,_chunks(rlist, nrow)) | |
|
624 | chk = list(map(max,_chunks(rlist, nrow))) | |
|
625 | 625 | sumlength = sum(chk) |
|
626 | 626 | ncols = len(chk) |
|
627 | 627 | if sumlength+separator_size*(ncols-1) <= displaywidth : |
@@ -694,7 +694,7 def compute_item_matrix(items, empty=None, *args, **kwargs) : | |||
|
694 | 694 | 'rows_numbers': 5}) |
|
695 | 695 | |
|
696 | 696 | """ |
|
697 | info = _find_optimal(map(len, items), *args, **kwargs) | |
|
697 | info = _find_optimal(list(map(len, items)), *args, **kwargs) | |
|
698 | 698 | nrow, ncol = info['rows_numbers'], info['columns_numbers'] |
|
699 | 699 | return ([[ _get_or_default(items, c*nrow+i, default=empty) for c in range(ncol) ] for i in range(nrow) ], info) |
|
700 | 700 |
General Comments 0
You need to be logged in to leave comments.
Login now