Skip to content

Commit 0e9649d

Browse files
authored
Merge pull request #178 from mate-academy/add-inspect
added inspect
2 parents 32dc1dd + 874f08b commit 0e9649d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

tests/test_main.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import inspect
2+
13
import pytest
24

35
from app.main import count_occurrences
@@ -12,19 +14,17 @@
1214
("Abracadabra", "A", 5),
1315
("", "a", 0),
1416
("Samsung", "b", 0),
15-
]
17+
],
1618
)
1719
def test_count_occurrences(phrase, letter, count):
1820
assert count_occurrences(phrase, letter) == count, (
1921
f"Function 'count_occurrences' should return {count}, "
2022
f"when 'phrase'='{phrase}' and 'letter'='{letter}'"
2123
)
2224

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'"
3025

26+
def test_removed_comment():
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)