import py from py.__.apigen import htmlgen from py.__.apigen.linker import Linker def test_create_namespace_tree(): tree = htmlgen.create_namespace_tree(['foo.bar.baz']) assert tree == {'': ['foo'], 'foo': ['foo.bar'], 'foo.bar': ['foo.bar.baz']} tree = htmlgen.create_namespace_tree(['foo.bar.baz', 'foo.bar.qux']) assert tree == {'': ['foo'], 'foo': ['foo.bar'], 'foo.bar': ['foo.bar.baz', 'foo.bar.qux']} tree = htmlgen.create_namespace_tree(['pkg.sub.func', 'pkg.SomeClass', 'pkg.SomeSubClass']) assert tree == {'': ['pkg'], 'pkg.sub': ['pkg.sub.func'], 'pkg': ['pkg.sub', 'pkg.SomeClass', 'pkg.SomeSubClass']} def test_build_navitem_html(): l = Linker() l.set_link('spam.eggs.foo', 'foo.html') h = htmlgen.build_navitem_html(l, 'foo', 'spam.eggs.foo', 0, False) assert unicode(h) == u'
' h = htmlgen.build_navitem_html(l, 'bar', 'spam.eggs.foo', 1, True) assert unicode(h) == (u'