Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_table(mocker):
"""Test basic table rendering
"""
import lookatme.widgets.table
mocker.patch.object(lookatme.config, "LOG")
fake_config = mocker.patch.object(lookatme.render.markdown_block, "config")
mocker.patch.object(lookatme.widgets.table, "config", fake_config)
fake_config.STYLE = {
"table": {
"column_spacing": 1,
"header_divider": "-",
},
}
rendered = render_markdown("""
| H1 | H2 | H3 |
|:--------|:------:|-------:|
| 1value1 | value2 | value3 |
| 1 | 2 | 3 |
""")
assert len(rendered) == 4
def test_file_loader_relative(tmpdir, mocker):
"""Test the built-in file loader extension
"""
mocker.patch.object(lookatme.config, "LOG")
mocker.patch.object(lookatme.config, "SLIDE_SOURCE_DIR", str(tmpdir))
fake_config = mocker.patch.object(lookatme.render.markdown_block, "config")
mocker.patch.object(lookatme.render.pygments, "config", fake_config)
fake_config.STYLE = TEST_STYLE
tmppath = tmpdir.join("test.py")
tmppath.write("print('hello')")
rendered = render_markdown(f"""
```file
path: test.py
relative: true
""")
stripped_rows = [
b'',
b"print('hello')",
* ``urwid.Widget`` - A single widget to render. Will be added to
``stack[-1]`` automatically.
"""
self._log.debug(f"Rendering slide {slide_num}")
start = time.time()
tmp_pile = urwid.Pile([])
stack = [tmp_pile]
for token in to_render.tokens:
self._log.debug(f"{' '*len(stack)}Rendering token {token}")
last_stack = stack[-1]
last_stack_len = len(stack)
#render_token = getattr(lam_md, f"render_{token['type']}", lambda *args: None)
render_token = getattr(lam_md, f"render_{token['type']}")
res = render_token(token, stack[-1], stack, self.loop)
if len(stack) > last_stack_len:
self._propagate_meta(last_stack, stack[-1])
if res is None:
continue
pile_add(last_stack, res)
total = time.time() - start
self._log.debug(f"Rendered slide {slide_num} in {total}")
return tmp_pile.contents