File: test_expect_error.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 (47 lines) | stat: -rw-r--r-- 1,093 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
def test_expect_error(testdir):
    string = """
    <!--pytest.mark.xfail-->
    ```python
    raise RuntimeError()
    ```
    """
    testdir.makefile(".md", string)
    result = testdir.runpytest("--codeblocks")
    result.assert_outcomes(xfailed=1)


def test_expect_error_runtimeerror(testdir):
    string = """
    <!--pytest.mark.xfail(raises=RuntimeError)-->
    ```python
    raise RuntimeError()
    ```
    """
    testdir.makefile(".md", string)
    result = testdir.runpytest("--codeblocks")
    result.assert_outcomes(xfailed=1)


def test_expect_error_indexerror(testdir):
    string = """
    <!--pytest.mark.xfail(raises=IndexError)-->
    ```python
    raise RuntimeError()
    ```
    """
    testdir.makefile(".md", string)
    result = testdir.runpytest("--codeblocks")
    result.assert_outcomes(failed=1)


def test_expect_error_fail(testdir):
    string1 = """
    Lorem ipsum
    <!--pytest.mark.xfail-->
    ```python
    1 + 1
    ```
    """
    testdir.makefile(".md", string1)
    result = testdir.runpytest("--codeblocks")
    result.assert_outcomes(xpassed=1)