Created
September 23, 2011 16:58
-
-
Save iffy/1237869 to your computer and use it in GitHub Desktop.
minmal doctest example
This file contains hidden or 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
import doctest | |
import work | |
suite = DocTestSuite(work) | |
# What goes here? |
This file contains hidden or 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
$ python run.py | |
---------------------------------------------------------------------- | |
Ran 0 tests in 0.000s | |
OK |
This file contains hidden or 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
import unittest | |
import sys | |
# this is the code in someone else's package -- I can't change this. | |
suite = unittest.TestSuite() | |
module = __import__('work', None, None, [""]) | |
suite.addTest(unittest.defaultTestLoader.loadTestsFromModule(module)) | |
runner = unittest.TextTestRunner() | |
result = runner.run(suite) | |
sys.exit(not result.wasSuccessful()) |
This file contains hidden or 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
def f(): | |
""" | |
>>> print 'foo' | |
bar | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment