Show More
@@ -87,7 +87,7 b' class FileLink(object):' | |||
|
87 | 87 | """ |
|
88 | 88 | if isdir(path): |
|
89 | 89 | raise ValueError,\ |
|
90 |
("Cannot display a directory |
|
|
90 | ("Cannot display a directory using FileLink. " | |
|
91 | 91 | "Use FileLinks to display '%s'." % path) |
|
92 | 92 | self.path = path |
|
93 | 93 | self.url_prefix = url_prefix |
@@ -171,6 +171,10 b' class FileLinks(FileLink):' | |||
|
171 | 171 | place, can be passed here to support alternative formatting. |
|
172 | 172 | |
|
173 | 173 | """ |
|
174 | if isfile(path): | |
|
175 | raise ValueError,\ | |
|
176 | ("Cannot display a file using FileLinks. " | |
|
177 | "Use FileLink to display '%s'." % path) | |
|
174 | 178 | self.included_suffixes = included_suffixes |
|
175 | 179 | # remove trailing slashs for more consistent output formatting |
|
176 | 180 | path = path.rstrip('/') |
@@ -58,6 +58,12 b' def test_existing_path_FileLink_repr():' | |||
|
58 | 58 | expected = tf.name |
|
59 | 59 | nt.assert_equal(actual,expected) |
|
60 | 60 | |
|
61 | def test_error_on_directory_to_FileLink(): | |
|
62 | """FileLink: Raises error when passed directory | |
|
63 | """ | |
|
64 | td = mkdtemp() | |
|
65 | nt.assert_raises(ValueError,display.FileLink,td) | |
|
66 | ||
|
61 | 67 | #-------------------------- |
|
62 | 68 | # FileLinks tests |
|
63 | 69 | #-------------------------- |
@@ -138,3 +144,10 b' def test_existing_path_FileLinks_repr_alt_formatter():' | |||
|
138 | 144 | # We compare the sorted list of links here as that's more reliable |
|
139 | 145 | nt.assert_equal(actual,expected) |
|
140 | 146 | |
|
147 | def test_error_on_file_to_FileLinks(): | |
|
148 | """FileLinks: Raises error when passed file | |
|
149 | """ | |
|
150 | td = mkdtemp() | |
|
151 | tf1 = NamedTemporaryFile(dir=td) | |
|
152 | nt.assert_raises(ValueError,display.FileLinks,tf1.name) | |
|
153 |
General Comments 0
You need to be logged in to leave comments.
Login now