Skip to content

Commit

Permalink
example and travis
Browse files Browse the repository at this point in the history
  • Loading branch information
jhayer committed Dec 4, 2018
1 parent 5e2b8f7 commit b547684
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.pytest_cache
__pycache__
28 changes: 28 additions & 0 deletions .travis.yml
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

37 changes: 37 additions & 0 deletions example.py
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()

0 comments on commit b547684

Please sign in to comment.