def test_runner_uses_source_from_filename(self) -> None:
    doc = Document()
    source = nbformat.v4.new_notebook()
    result = {}

    def load(filename):
        handler = bahn.NotebookHandler(filename=filename)
        handler.modify_document(doc)
        result['handler'] = handler
        result['filename'] = filename
    with_script_contents(source, load)
    assert (result['handler']._runner.path == result['filename'])
    if (version.parse(nbconvert.__version__) < version.parse('5.4')):
        expected_source = '\n# coding: utf-8\n'
    else:
        expected_source = '#!/usr/bin/env python\n# coding: utf-8\n'
    assert (result['handler']._runner.source == expected_source)
    assert (not doc.roots)
def test_runner_uses_source_from_filename(self) -> None:
    doc = Document()
    source = nbformat.v4.new_notebook()
    result = {}

    def load(filename):
        handler = bahn.NotebookHandler(filename=filename)
        handler.modify_document(doc)
        result['handler'] = handler
        result['filename'] = filename
    with_script_contents(source, load)
    assert (result['handler']._runner.path == result['filename'])
    if (version.parse(nbconvert.__version__) < version.parse('5.4')):
        expected_source = '\n# coding: utf-8\n'
    else:
        expected_source = '#!/usr/bin/env python\n# coding: utf-8\n'
    assert (result['handler']._runner.source == expected_source)
    assert (not doc.roots)