

def test_python_headers():
    cells = _exec_test_file('ex2')
    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)
    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)
    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)
    converted = convert(cells, to='python', to_kwargs={
        'keep_markdown': 'all',
    })
    assert (len(converted.splitlines()) == 72)
    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