Created
February 16, 2011 02:25
-
-
Save alfredodeza/828739 to your computer and use it in GitHub Desktop.
A proof of concept for better readability in tests
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
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') |
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
$ 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