Skip to content

Commit

Permalink
inspect for function, not for all the file
Browse files Browse the repository at this point in the history
  • Loading branch information
Nattalli committed Nov 4, 2022
1 parent b216171 commit 874f08b
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions tests/test_main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import pytest
import inspect

from app import main
import pytest

from app.main import count_occurrences


@pytest.mark.parametrize(
"phrase,letter,count",
Expand All @@ -12,16 +14,17 @@
("Abracadabra", "A", 5),
("", "a", 0),
("Samsung", "b", 0),
]
],
)
def test_count_occurrences(phrase, letter, count):
assert main.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(main)
assert "# write your code here" not in lines, ("You have to"
" remove the unnecessary comment '# write your code here'")
lines = inspect.getsource(count_occurrences)
assert "# write your code here" not in lines, (
"You have to" " remove the unnecessary comment '# write your code here'"
)

0 comments on commit 874f08b

Please sign in to comment.