summaryrefslogtreecommitdiffstats
path: root/tests/test_cli.py
blob: 4725f930599e3ea96786952d67fd2fdd7e99c8b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from unittest import mock

from myst_parser.cli import print_anchors


def test_print_anchors():
    from io import StringIO

    in_stream = StringIO("# a\n\n## b\n\ntext")
    out_stream = StringIO()
    with mock.patch("sys.stdin", in_stream):
        with mock.patch("sys.stdout", out_stream):
            print_anchors(["-l", "1"])
    out_stream.seek(0)
    assert out_stream.read().strip() == '<h1 id="a"></h1>'