##// END OF EJS Templates
recursive==False uses next(iter) for PY3 compatability; added tests to make sure it doesn't recurse
Doug Blank -
Show More
@@ -524,7 +524,7 b' class FileLinks(FileLink):'
524 524 if self.recursive:
525 525 walked_dir = list(walk(self.path))
526 526 else:
527 walked_dir = [walk(self.path).next()]
527 walked_dir = [next(walk(self.path))]
528 528 walked_dir.sort()
529 529 for dirname, subdirs, fnames in walked_dir:
530 530 result_lines += self.notebook_display_formatter(dirname, fnames, self.included_suffixes)
@@ -537,7 +537,7 b' class FileLinks(FileLink):'
537 537 if self.recursive:
538 538 walked_dir = list(walk(self.path))
539 539 else:
540 walked_dir = [walk(self.path).next()]
540 walked_dir = [next(walk(self.path))]
541 541 walked_dir.sort()
542 542 for dirname, subdirs, fnames in walked_dir:
543 543 result_lines += self.terminal_display_formatter(dirname, fnames, self.included_suffixes)
@@ -156,7 +156,23 b' def test_error_on_file_to_FileLinks():'
156 156 tf1 = NamedTemporaryFile(dir=td)
157 157 nt.assert_raises(ValueError,display.FileLinks,tf1.name)
158 158
159 def test_recursive_FileLinks():
160 """FileLinks: Does not recurse when recursive=False
161 """
162 td = mkdtemp()
163 tf = NamedTemporaryFile(dir=td)
164 subtd = mkdtemp(dir=td)
165 subtf = NamedTemporaryFile(dir=subtd)
166 fl = display.FileLinks(td)
167 actual = str(fl)
168 actual = actual.split('\n')
169 nt.assert_equal(len(actual), 4, actual)
170 fl = display.FileLinks(td, recursive=False)
171 actual = str(fl)
172 actual = actual.split('\n')
173 nt.assert_equal(len(actual), 2, actual)
174
159 175 @skipif_not_numpy
160 176 def test_audio_from_file():
161 177 path = pjoin(dirname(__file__), 'test.wav')
162 display.Audio(filename=path) No newline at end of file
178 display.Audio(filename=path)
General Comments 0
You need to be logged in to leave comments. Login now