def test_render_name_function(): def function(): pass assert get_render_name(function) == "function" def render_function(): pass assert get_render_name(function) == "function"
def test_render_name_method(): class Renderer: def method(self): pass def render_method(self): pass renderer = Renderer() assert get_render_name(renderer.method) == "renderer__method" assert get_render_name(renderer.render_method) == "renderer__method"
def register(self, pattern: str, render: Render, render_name: str = "") -> None: if not render_name: render_name = get_render_name(render) self.patterns[render_name] = pattern self.renders[render_name] = render
def register(self, pattern: str, render: Render, render_name: str = "") -> type: if not render_name: render_name = get_render_name(render) cell_class = make_cell_class(pattern, render, render_name) self.cell_classes[render_name] = cell_class pattern = rename_pattern(pattern, render_name) self.renders[render_name] = render self.patterns[render_name] = pattern self.pattern = None # Delete the pattern compiled before. return cell_class
def test_render_name_method_with_name(): class Renderer: def __init__(self, name): self.name = name def method(self): pass def render_method(self): pass renderer = Renderer("example") assert get_render_name(renderer.method) == "renderer__example__method"