Show More
@@ -3,7 +3,7 b'' | |||||
3 | Authors : MinRK, gregcaporaso, dannystaple |
|
3 | Authors : MinRK, gregcaporaso, dannystaple | |
4 | """ |
|
4 | """ | |
5 | from os.path import exists, isfile, splitext, abspath, join, isdir |
|
5 | from os.path import exists, isfile, splitext, abspath, join, isdir | |
6 | from os import walk, sep |
|
6 | from os import walk, sep, fsdecode | |
7 |
|
7 | |||
8 | from IPython.core.display import DisplayObject |
|
8 | from IPython.core.display import DisplayObject | |
9 |
|
9 | |||
@@ -334,7 +334,7 b' class FileLink(object):' | |||||
334 | if isdir(path): |
|
334 | if isdir(path): | |
335 | raise ValueError("Cannot display a directory using FileLink. " |
|
335 | raise ValueError("Cannot display a directory using FileLink. " | |
336 | "Use FileLinks to display '%s'." % path) |
|
336 | "Use FileLinks to display '%s'." % path) | |
337 | self.path = path |
|
337 | self.path = fsdecode(path) | |
338 | self.url_prefix = url_prefix |
|
338 | self.url_prefix = url_prefix | |
339 | self.result_html_prefix = result_html_prefix |
|
339 | self.result_html_prefix = result_html_prefix | |
340 | self.result_html_suffix = result_html_suffix |
|
340 | self.result_html_suffix = result_html_suffix |
@@ -14,6 +14,11 b'' | |||||
14 | #----------------------------------------------------------------------------- |
|
14 | #----------------------------------------------------------------------------- | |
15 | from tempfile import NamedTemporaryFile, mkdtemp |
|
15 | from tempfile import NamedTemporaryFile, mkdtemp | |
16 | from os.path import split, join as pjoin, dirname |
|
16 | from os.path import split, join as pjoin, dirname | |
|
17 | import sys | |||
|
18 | try: | |||
|
19 | import pathlib | |||
|
20 | except ImportError: | |||
|
21 | pass | |||
17 |
|
22 | |||
18 | # Third-party imports |
|
23 | # Third-party imports | |
19 | import nose.tools as nt |
|
24 | import nose.tools as nt | |
@@ -33,6 +38,9 b' from IPython.testing.decorators import skipif_not_numpy' | |||||
33 | def test_instantiation_FileLink(): |
|
38 | def test_instantiation_FileLink(): | |
34 | """FileLink: Test class can be instantiated""" |
|
39 | """FileLink: Test class can be instantiated""" | |
35 | fl = display.FileLink('example.txt') |
|
40 | fl = display.FileLink('example.txt') | |
|
41 | # TODO: remove if when only Python >= 3.6 is supported | |||
|
42 | if sys.version_info >= (3, 6): | |||
|
43 | fl = display.FileLink(pathlib.PurePath('example.txt')) | |||
36 |
|
44 | |||
37 | def test_warning_on_non_existant_path_FileLink(): |
|
45 | def test_warning_on_non_existant_path_FileLink(): | |
38 | """FileLink: Calling _repr_html_ on non-existant files returns a warning |
|
46 | """FileLink: Calling _repr_html_ on non-existant files returns a warning |
General Comments 0
You need to be logged in to leave comments.
Login now