Skip to content

Commit 874f08b

Browse files
committed
inspect for function, not for all the file
1 parent b216171 commit 874f08b

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

tests/test_main.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import pytest
21
import inspect
32

4-
from app import main
3+
import pytest
4+
5+
from app.main import count_occurrences
6+
57

68
@pytest.mark.parametrize(
79
"phrase,letter,count",
@@ -12,16 +14,17 @@
1214
("Abracadabra", "A", 5),
1315
("", "a", 0),
1416
("Samsung", "b", 0),
15-
]
17+
],
1618
)
1719
def test_count_occurrences(phrase, letter, count):
18-
assert main.count_occurrences(phrase, letter) == count, (
20+
assert count_occurrences(phrase, letter) == count, (
1921
f"Function 'count_occurrences' should return {count}, "
2022
f"when 'phrase'='{phrase}' and 'letter'='{letter}'"
2123
)
2224

2325

2426
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'")
27+
lines = inspect.getsource(count_occurrences)
28+
assert "# write your code here" not in lines, (
29+
"You have to" " remove the unnecessary comment '# write your code here'"
30+
)

0 commit comments

Comments
 (0)