Coverage for tests/test_validator.py: 100.00%

6 statements  

« prev     ^ index     » next       coverage.py v7.2.3, created at 2023-04-16 20:19 +0200

1"""Tests for the `validator` function.""" 

2 

3import pytest 

4from markdown.core import Markdown 

5 

6from markdown_exec import validator 

7 

8 

9@pytest.mark.parametrize( 

10 ("exec_value", "expected"), 

11 [ 

12 ("yes", True), 

13 ("YES", True), 

14 ("on", True), 

15 ("ON", True), 

16 ("whynot", True), 

17 ("true", True), 

18 ("TRUE", True), 

19 ("1", True), 

20 ("-1", True), 

21 ("0", False), 

22 ("no", False), 

23 ("NO", False), 

24 ("off", False), 

25 ("OFF", False), 

26 ("false", False), 

27 ("FALSE", False), 

28 ], 

29) 

30def test_validate(md: Markdown, exec_value: str, expected: bool) -> None: 

31 """Assert the validator returns True or False given inputs. 

32 

33 Parameters: 

34 md: A Markdown instance. 

35 exec_value: The exec option value, passed from the code block. 

36 expected: Expected validation result. 

37 """ 

38 assert validator("whatever", inputs={"exec": exec_value}, options={}, attrs={}, md=md) is expected