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)
|