From b24126ce347c175519accf49a1662b6d1902f592 2012-10-28 19:25:27 From: Greg Caporaso Date: 2012-10-28 19:25:27 Subject: [PATCH] added tests of passing alternative formatter functions --- diff --git a/IPython/lib/tests/test_display.py b/IPython/lib/tests/test_display.py index 998a615..8017679 100644 --- a/IPython/lib/tests/test_display.py +++ b/IPython/lib/tests/test_display.py @@ -84,6 +84,24 @@ def test_existing_path_FileLinks(): # We compare the sorted list of links here as that's more reliable nt.assert_equal(actual,expected) +def test_existing_path_FileLinks_alt_formatter(): + """ Calling _repr_html_ functions as expected with an alternative formatter + """ + td = mkdtemp() + tf1 = NamedTemporaryFile(dir=td) + tf2 = NamedTemporaryFile(dir=td) + def fake_formatter(output_lines,dirname,fnames): + output_lines.extend(["hello","world"]) + return + fl = display.FileLinks(td,notebook_display_formatter=fake_formatter) + actual = fl._repr_html_() + actual = actual.split('\n') + actual.sort() + expected = ["hello","world"] + expected.sort() + # We compare the sorted list of links here as that's more reliable + nt.assert_equal(actual,expected) + def test_existing_path_FileLinks_repr(): """ Calling repr() functions as expected on existing directory """ td = mkdtemp() @@ -97,6 +115,24 @@ def test_existing_path_FileLinks_repr(): expected.sort() # We compare the sorted list of links here as that's more reliable nt.assert_equal(actual,expected) + +def test_existing_path_FileLinks_repr_alt_formatter(): + """ Calling repr() functions as expected with an alternative formatter + """ + td = mkdtemp() + tf1 = NamedTemporaryFile(dir=td) + tf2 = NamedTemporaryFile(dir=td) + def fake_formatter(output_lines,dirname,fnames): + output_lines.extend(["hello","world"]) + return + fl = display.FileLinks(td,terminal_display_formatter=fake_formatter) + actual = repr(fl) + actual = actual.split('\n') + actual.sort() + expected = ["hello","world"] + expected.sort() + # We compare the sorted list of links here as that's more reliable + nt.assert_equal(actual,expected) #-------------------------- # DirectoryLink tests