Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@alfredodeza
Created February 16, 2011 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alfredodeza/828739 to your computer and use it in GitHub Desktop.
Save alfredodeza/828739 to your computer and use it in GitHub Desktop.
A proof of concept for better readability in tests
from testrunner import describe, it, before, after
import MyClass
with describe("My class can add"):
with before:
c = MyClass()
with after:
"clean up goes here"
with it("adds two and two"):
assert c.add(2,2) == 4
with it("adds negatives"):
assert c.add(10, -10) == 0
with it.raises("adding int and string", TypeError):
c.add(10, 'foo')
$ testrunner
My class can add
- adds two and two
- adds negatives
- raises adding int and string
3/3 tests passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment