1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| import pytest
@pytest.mark.parametrize( "eval_str,expected", [("8", 8), ("list((1,2,3))",[1,2,3]), pytest.param("7*8", 64, marks=pytest.mark.xfail)], ) def test_eval(eval_str, expected): assert eval(eval_str) == expected
PS D:\Projects\test> pytest ============================================ test session starts ============================================ platform win32 -- Python 3.11.4, pytest-7.4.0, pluggy-1.3.0 rootdir: D:\Projects\test collected 3 items
test_demo.py ..x [100%]
======================================= 2 passed, 1 xfailed in 0.09s ========================================
|