Skip to content

Commit 880bb71

Browse files
committed
Add more tests to improve test coverage
1 parent 6c19b8d commit 880bb71

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

tests/demo_code.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,11 @@
77
pass
88
else: # pragma: no cover (<py38)
99
pass
10+
11+
import platform
12+
13+
if platform.processor() != "x86_64": # pragma: no cover
14+
pass
15+
16+
if platform.python_branch(): # pragma: no cover (hard to test)
17+
pass

tests/test_grammar.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# stdlib
22
import platform
33
import sys
4-
from typing import Tuple
4+
from typing import Tuple, Type
55

66
# 3rd party
77
import pytest
@@ -80,13 +80,17 @@ def test_grammar_current_platform_etc():
8080
assert evaluate_exclude(f"{platform.system()}")
8181

8282

83-
@pytest.mark.parametrize("expression", [
84-
"36",
85-
"36 and",
86-
"py36 and",
87-
"windows and",
88-
"!bpython and pypy",
83+
@pytest.mark.parametrize("expression, exception", [
84+
("36", ParseBaseException),
85+
("36 and", ParseBaseException),
86+
("py36 and", ParseBaseException),
87+
("windows and", ParseBaseException),
88+
("!bpython and pypy", ParseBaseException),
89+
("<py38+", SyntaxError),
8990
])
90-
def test_bad_grammar(expression: str):
91-
with pytest.raises(ParseBaseException):
91+
def test_bad_grammar(expression: str, exception: Type[Exception]):
92+
with pytest.raises(exception):
9293
evaluate_exclude(expression)
94+
95+
96+
# TODO: tests for LogicalOp classes
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Name Stmts Miss Cover
22
----------------------------------------
3-
tests/demo_code.py 3 0 100%
3+
tests/demo_code.py 4 0 100%
44
----------------------------------------
5-
TOTAL 3 0 100%
5+
TOTAL 4 0 100%

0 commit comments

Comments
 (0)