MCPcopy Create free account
hub / github.com/ipython/ipython / test_existing_path_FileLinks

Function test_existing_path_FileLinks

IPython/lib/tests/test_display.py:95–114  ·  view source on GitHub ↗

FileLinks: Calling _repr_html_ functions as expected on existing dir

()

Source from the content-addressed store, hash-verified

93 nt.assert_true(fls._repr_html_().startswith('Path (<tt>example</tt>)'))
94
95def test_existing_path_FileLinks():
96 """FileLinks: Calling _repr_html_ functions as expected on existing dir
97 """
98 td = mkdtemp()
99 tf1 = NamedTemporaryFile(dir=td)
100 tf2 = NamedTemporaryFile(dir=td)
101 fl = display.FileLinks(td)
102 actual = fl._repr_html_()
103 actual = actual.split('\n')
104 actual.sort()
105 # the links should always have forward slashes, even on windows, so replace
106 # backslashes with forward slashes here
107 expected = ["%s/<br>" % td,
108 "&nbsp;&nbsp;<a href='%s' target='_blank'>%s</a><br>" %\
109 (tf2.name.replace("\\","/"),split(tf2.name)[1]),
110 "&nbsp;&nbsp;<a href='%s' target='_blank'>%s</a><br>" %\
111 (tf1.name.replace("\\","/"),split(tf1.name)[1])]
112 expected.sort()
113 # We compare the sorted list of links here as that's more reliable
114 nt.assert_equal(actual,expected)
115
116def test_existing_path_FileLinks_alt_formatter():
117 """FileLinks: Calling _repr_html_ functions as expected w/ an alt formatter

Callers

nothing calls this directly

Calls 2

sortMethod · 0.80
_repr_html_Method · 0.45

Tested by

no test coverage detected