I was following python programming course and with the unit test chapter I updated the main file and the test files as described in this problem set page. Now I'm sure that my tests are running fine as when I run pytest test_twttr.py
it runs all the tests. I have also made sure that I'm not running any print
command within the shorten
method. However, when I run check50 command, it fails on the second step where it says it got exit code 1, instead of 0. and I have spent good amount of time to investigate where the problem lies, but couldn't found any so far. So if anyone could help, I would then be able to proceed with rest of the coursework. Thanks.
My test_twttr.py
looks like this
from twttr import shorten
def test_replaces_vowels():
assert shorten('Twitter') == 'Twttr'
def test_replaces_vowels_in_capital():
assert shorten("WHAT's your name?") == "WHT's yr nm?"
def test_replaces_vowels_in_lowercase():
assert shorten('able') == 'bl'
def test_omits_uppercase():
assert shorten('CS50') == 'CS50'
def test_omits_numbers():
assert shorten(123) == '123'
def test_omits_punctuations():
assert shorten('a,d!') == ',d!'
and here is the code from twttr.py
:
def main(): userInput = input('Input: ') updatedInput = shorten(userInput) print('Output: ' + updatedInput) # go through each letter and remove letter if it is vowel def shorten(userData): userData = str(userData) updatedText = '' loopCount = 0 letterCount = len(userData) while loopCount
correct twttr.py passes all test_twttr checks
? If, so this test is running yourtest_twttr.py
against theirtwttr.py
that is known to be correct. When it does, something goes wrong in yourtest_twttr.py
. It's hard to give more help without seeing yourtest_twttr.py
code. It should only be asserting a few test statements.test_twttr.py
. it passes all when I runpytest test_twttr.py
: from twttr import shorten def test_replaces_vowels(): assert shorten('Twitter') == 'Twttr' def test_replaces_vowels_in_capital(): assert shorten("WHAT's your name?") == "WHT's yr nm?" def test_replaces_vowels_in_lowercase(): assert shorten('able') == 'bl' def test_omits_uppercase(): assert shorten('CS50') == 'CS50' def test_omits_numbers(): assert shorten(123) == '123' def test_omits_punctuations(): assert shorten('a,d!') == ',d!'test_twttr.py
andtwttr.py
. unfortunately it's not showing all the contents from mytwttr.py
file.