import py from py.__.apigen.rest.htmlhandlers import PageHandler def test_breadcrumb(): h = PageHandler() for fname, expected in [ ('module_py', 'py'), ('module_py.test', 'py.test'), ('class_py.test', ('py.' 'test')), ('class_py.test.foo', ('py.test.' 'foo')), ('class_py.test.foo.bar', ('py.test.foo.' 'bar')), ('function_foo', 'foo'), ('function_foo.bar', ('foo.' 'bar')), ('function_foo.bar.baz', ('foo.bar.' 'baz')), ('method_foo.bar', ('foo.' 'bar')), ('method_foo.bar.baz', ('foo.' 'bar.' 'baz')), ('method_foo.bar.baz.qux', ('foo.bar.' 'baz.' 'qux')), ]: html = ''.join([unicode(el) for el in h.breadcrumb(fname)]) print fname print html assert html == expected