Skip to content

Commit

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

from app.main import count_occurrences

from app import main

@pytest.mark.parametrize(
"phrase,letter,count",
Expand All @@ -15,16 +15,13 @@
]
)
def test_count_occurrences(phrase, letter, count):
assert count_occurrences(phrase, letter) == count, (
assert main.count_occurrences(phrase, letter) == count, (
f"Function 'count_occurrences' should return {count}, "
f"when 'phrase'='{phrase}' and 'letter'='{letter}'"
)


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

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

0 comments on commit b216171

Please sign in to comment.