##// 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 if self.recursive:
524 if self.recursive:
525 walked_dir = list(walk(self.path))
525 walked_dir = list(walk(self.path))
526 else:
526 else:
527 walked_dir = [walk(self.path).next()]
527 walked_dir = [next(walk(self.path))]
528 walked_dir.sort()
528 walked_dir.sort()
529 for dirname, subdirs, fnames in walked_dir:
529 for dirname, subdirs, fnames in walked_dir:
530 result_lines += self.notebook_display_formatter(dirname, fnames, self.included_suffixes)
530 result_lines += self.notebook_display_formatter(dirname, fnames, self.included_suffixes)
@@ -537,7 +537,7 b' class FileLinks(FileLink):'
537 if self.recursive:
537 if self.recursive:
538 walked_dir = list(walk(self.path))
538 walked_dir = list(walk(self.path))
539 else:
539 else:
540 walked_dir = [walk(self.path).next()]
540 walked_dir = [next(walk(self.path))]
541 walked_dir.sort()
541 walked_dir.sort()
542 for dirname, subdirs, fnames in walked_dir:
542 for dirname, subdirs, fnames in walked_dir:
543 result_lines += self.terminal_display_formatter(dirname, fnames, self.included_suffixes)
543 result_lines += self.terminal_display_formatter(dirname, fnames, self.included_suffixes)
@@ -156,6 +156,22 b' def test_error_on_file_to_FileLinks():'
156 tf1 = NamedTemporaryFile(dir=td)
156 tf1 = NamedTemporaryFile(dir=td)
157 nt.assert_raises(ValueError,display.FileLinks,tf1.name)
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 @skipif_not_numpy
175 @skipif_not_numpy
160 def test_audio_from_file():
176 def test_audio_from_file():
161 path = pjoin(dirname(__file__), 'test.wav')
177 path = pjoin(dirname(__file__), 'test.wav')
General Comments 0
You need to be logged in to leave comments. Login now