Skip to content

Commit b216171

Browse files
committed
added inspect
1 parent 9542cb5 commit b216171

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

tests/test_main.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
2+
import inspect
23

3-
from app.main import count_occurrences
4-
4+
from app import main
55

66
@pytest.mark.parametrize(
77
"phrase,letter,count",
@@ -15,16 +15,13 @@
1515
]
1616
)
1717
def test_count_occurrences(phrase, letter, count):
18-
assert count_occurrences(phrase, letter) == count, (
18+
assert main.count_occurrences(phrase, letter) == count, (
1919
f"Function 'count_occurrences' should return {count}, "
2020
f"when 'phrase'='{phrase}' and 'letter'='{letter}'"
2121
)
2222

23-
24-
def test_removed_comment():
25-
import app
26-
with open(app.main.__file__, "r") as f:
27-
file_content = f.read()
28-
assert "# write your code here" not in file_content, \
29-
"You have to remove the unnecessary comment '# write your code here'"
3023

24+
def test_removed_comment():
25+
lines = inspect.getsource(main)
26+
assert "# write your code here" not in lines, ("You have to"
27+
" remove the unnecessary comment '# write your code here'")

0 commit comments

Comments
 (0)