-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.pytest_cache | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
sudo: false | ||
|
||
language: | ||
- python | ||
|
||
python: | ||
- 2.6 | ||
- 2.7 | ||
- 3.4 | ||
- 3.5 | ||
|
||
install: | ||
- pip install pytest pytest-cov python-coveralls | ||
|
||
script: | ||
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; | ||
then py.test -vv example.py --cov example; | ||
else py.test -vv example.py; | ||
fi | ||
|
||
after_success: | ||
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; | ||
then coveralls; | ||
fi | ||
|
||
notifications: | ||
email: false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
def reverse_words(s): | ||
""" | ||
Reverses order or words in string s. | ||
""" | ||
words = s.split() | ||
words_reversed = words[::-1] | ||
return ' '.join(words_reversed) | ||
|
||
|
||
def test_reverse_words(): | ||
assert reverse_words('dogs hate cats') == 'cats hate dogs' | ||
assert reverse_words('dog eat dog') == 'dog eat dog' | ||
assert reverse_words('one two three four') == 'four three two one' | ||
|
||
|
||
def get_word_lengths(s): | ||
""" | ||
Returns a list of integers representing | ||
the word lengths in string s. | ||
""" | ||
# uncomment next line in step 9 | ||
# return [len(word) for word in s.split()] | ||
return None | ||
|
||
|
||
# uncomment this function in step 6 | ||
#def test_get_word_lengths(): | ||
# text = "Three tomatoes are walking down the street" | ||
# assert get_word_lengths(text) == [5, 8, 3, 7, 4, 3, 6] | ||
|
||
|
||
def obscure_function(): | ||
""" | ||
Example of a function that is never tested. | ||
""" | ||
do_something_strange() | ||
|