File: test_errors.py

package info (click to toggle)
pytest-codeblocks 0.17.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 180 kB
  • sloc: python: 699; makefile: 34
file content (27 lines) | stat: -rw-r--r-- 478 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import io

import pytest

import pytest_codeblocks


def test_unclosed(testdir):
    string = """
    ```python
    1 + 2 + 3
    """
    testdir.makefile(".md", string)
    result = testdir.runpytest("--codeblocks")
    result.assert_outcomes(errors=1)


def test_maxlines():
    unclosed = io.StringIO(
        """
    ```python
    1 + 2 + 3
    ```
    """
    )
    with pytest.raises(RuntimeError):
        pytest_codeblocks.extract_from_buffer(unclosed, max_num_lines=1)