diff options
author | adim <devnull@localhost> | 2007-03-15 20:07:15 +0100 |
---|---|---|
committer | adim <devnull@localhost> | 2007-03-15 20:07:15 +0100 |
commit | ac8abd865c5c32d7f854cc45df4fb657f59f3617 (patch) | |
tree | 552f699578445e2c25be9f3d6bbd62693b3c41cd /pytest.py | |
parent | 79fa045ff9b9d5aec00ad1f2d266429d4678c31c (diff) | |
download | logilab-common-ac8abd865c5c32d7f854cc45df4fb657f59f3617.tar.gz |
improved output capture in testlib
- you can now self.start_capture() / self.stop_capture()
within a test function
- introduced a new printonly() method :
class MyTc(TestCase):
def test_foo(self):
self.printonly('logi')
print "logilab"
print "hello"
This example will only print logilab, not hello
Diffstat (limited to 'pytest.py')
-rw-r--r-- | pytest.py | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -178,6 +178,13 @@ def parseargs(): action="callback", help="Captures and prints standard out/err only on errors " "(only make sense when pytest run one test file)") + parser.add_option('-p', '--printonly', + # XXX: I wish I could use the callback action but it + # doesn't seem to be able to get the value + # associated to the option + action="store", dest="printonly", default=None, + help="Only prints lines matching specified pattern (implies capture) " + "(only make sense when pytest run one test file)") parser.add_option('-q', '--quiet', callback=rebuild_cmdline, action="callback", help="Minimal output") @@ -193,6 +200,8 @@ def parseargs(): explicitfile = None # someone wants DBC testlib.ENABLE_DBC = options.dbc + if options.printonly: + newargs.extend(['--printonly', options.printonly]) # append additional args to the new sys.argv and let unittest_main # do the rest newargs += args |