Coverage for tests/test_reader.py: 100.00%
12 statements
« prev ^ index » next coverage.py v7.3.0, created at 2023-09-03 19:58 +0200
« prev ^ index » next coverage.py v7.3.0, created at 2023-09-03 19:58 +0200
1"""Tests for the `reader` module."""
3from __future__ import annotations
5from shellman.reader import _preprocess_lines, _preprocess_stream
6from tests.conftest import get_fake_script
9def test_preprocess_stream() -> None:
10 """Test pre-processing of a stream."""
11 script = get_fake_script("simple.sh")
12 with open(script) as stream:
13 assert list(_preprocess_stream(stream)) == [
14 (script, 3, "## \\brief Just a demo"),
15 (script, 4, "## \\desc This script actually does nothing."),
16 (script, 8, "## \\option -h, --help"),
17 (script, 9, "## Print this help and exit."),
18 (script, 14, "## \\usage demo [-h]"),
19 ]
22def test_preprocess_lines() -> None:
23 """Test pre-processing of lines."""
24 script = get_fake_script("simple.sh")
25 with open(script) as stream:
26 blocks = list(_preprocess_lines(_preprocess_stream(stream)))
27 assert blocks