def test_python_headers():
    cells = _exec_test_file('ex2')

    # Keep H1.
    converted = convert(cells, to='python',
                        to_kwargs={'keep_markdown': 'h1'})
    assert converted.startswith('# # Test notebook\n\n# some code in python')
    assert len(converted.splitlines()) == 30

    # Keep H2, H3.
    converted = convert(cells, to='python',
                        to_kwargs={'keep_markdown': 'h2,h3'})
    assert not converted.startswith('# # Test notebook\n\n# some code')
    assert len(converted.splitlines()) == 30

    # Keep all headers.
    converted = convert(cells, to='python',
                        to_kwargs={'keep_markdown': 'headers'})
    assert converted.startswith('# # Test notebook\n\n# some code in python')
    assert len(converted.splitlines()) == 32

    # Keep all Markdown.
    converted = convert(cells, to='python',
                        to_kwargs={'keep_markdown': 'all'})
    assert len(converted.splitlines()) == 72

    # Keep no Markdown.
    converted = convert(cells, to='python',
                        to_kwargs={'keep_markdown': False})
    assert len(converted.splitlines()) == 28
dataset/ETHPy150Open rossant/ipymd/ipymd/formats/tests/test_python.py/test_python_headers/original