Skip to content

Instantly share code, notes, and snippets.

@aptlyundecided
Created June 30, 2017 21:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aptlyundecided/0ee7648b65e851972897a647bdc266ab to your computer and use it in GitHub Desktop.
Save aptlyundecided/0ee7648b65e851972897a647bdc266ab to your computer and use it in GitHub Desktop.
"""Unit tests with Python"""
import datetime
# Create your function that returns the day of the week as an integer
def what_day():
"""Return an integer, representing the day of the week"""
# 0 - 6 [Mon - Sun]
return datetime.datetime.today().weekday()
# Test to make sure it's friday (4 == Friday)
def test_answer():
"""unit test for what_day - expects 4"""
assert what_day() == 4
"""
Printing results is un-needed!
Executing this code is different:
Instead of 'python yourfilename.py'
Use 'py.test yourfielname.py'
and you'll either see your file pass, or fail!
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment