##// END OF EJS Templates
added tests of passing alternative formatter functions
Greg Caporaso -
Show More
@@ -84,6 +84,24 b' def test_existing_path_FileLinks():'
84 # We compare the sorted list of links here as that's more reliable
84 # We compare the sorted list of links here as that's more reliable
85 nt.assert_equal(actual,expected)
85 nt.assert_equal(actual,expected)
86
86
87 def test_existing_path_FileLinks_alt_formatter():
88 """ Calling _repr_html_ functions as expected with an alternative formatter
89 """
90 td = mkdtemp()
91 tf1 = NamedTemporaryFile(dir=td)
92 tf2 = NamedTemporaryFile(dir=td)
93 def fake_formatter(output_lines,dirname,fnames):
94 output_lines.extend(["hello","world"])
95 return
96 fl = display.FileLinks(td,notebook_display_formatter=fake_formatter)
97 actual = fl._repr_html_()
98 actual = actual.split('\n')
99 actual.sort()
100 expected = ["hello","world"]
101 expected.sort()
102 # We compare the sorted list of links here as that's more reliable
103 nt.assert_equal(actual,expected)
104
87 def test_existing_path_FileLinks_repr():
105 def test_existing_path_FileLinks_repr():
88 """ Calling repr() functions as expected on existing directory """
106 """ Calling repr() functions as expected on existing directory """
89 td = mkdtemp()
107 td = mkdtemp()
@@ -97,6 +115,24 b' def test_existing_path_FileLinks_repr():'
97 expected.sort()
115 expected.sort()
98 # We compare the sorted list of links here as that's more reliable
116 # We compare the sorted list of links here as that's more reliable
99 nt.assert_equal(actual,expected)
117 nt.assert_equal(actual,expected)
118
119 def test_existing_path_FileLinks_repr_alt_formatter():
120 """ Calling repr() functions as expected with an alternative formatter
121 """
122 td = mkdtemp()
123 tf1 = NamedTemporaryFile(dir=td)
124 tf2 = NamedTemporaryFile(dir=td)
125 def fake_formatter(output_lines,dirname,fnames):
126 output_lines.extend(["hello","world"])
127 return
128 fl = display.FileLinks(td,terminal_display_formatter=fake_formatter)
129 actual = repr(fl)
130 actual = actual.split('\n')
131 actual.sort()
132 expected = ["hello","world"]
133 expected.sort()
134 # We compare the sorted list of links here as that's more reliable
135 nt.assert_equal(actual,expected)
100
136
101 #--------------------------
137 #--------------------------
102 # DirectoryLink tests
138 # DirectoryLink tests
General Comments 0
You need to be logged in to leave comments. Login now