forked from mate-academy/py-count-occurrences
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_main.py
30 lines (24 loc) · 789 Bytes
/
test_main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import inspect
import pytest
from app.main import count_occurrences
@pytest.mark.parametrize(
"phrase,letter,count",
[
("samsung", "a", 1),
("samsung is gnusmas", "s", 5),
("Samsung is gnusmas", "s", 5),
("Abracadabra", "A", 5),
("", "a", 0),
("Samsung", "b", 0),
],
)
def test_count_occurrences(phrase, letter, count):
assert count_occurrences(phrase, letter) == count, (
f"Function 'count_occurrences' should return {count}, "
f"when 'phrase'='{phrase}' and 'letter'='{letter}'"
)
def test_removed_comment():
lines = inspect.getsource(count_occurrences)
assert "# write your code here" not in lines, (
"You have to" " remove the unnecessary comment '# write your code here'"
)