def run(self): log("method Test") run()
def run2(self): log("method Test2") t = Run() t.run()
def run3(self): log("method Test3") run()
def other_run(): # Test too large values for stack_level # stack_level should exceed nosetests stack levels as well log("function other_run()", stack_level=100)
def run(): log("function run()")
# Stack containing two matching objects with capture_output() as out: t = Run2() t.run2() assert_equal(out[0], "[Run2.run2] method Test2\n" "[Run2.run2] method Test\n" "[Run2.run2] function run()\n") # Stack containing one matching object with capture_output() as out: t = Run() t.run() assert_equal(out[0], "[Run.run] method Test\n[Run.run] function run()\n") # Stack containing no object with capture_output() as out: run() assert_equal(out[0], "[run] function run()\n") # Test stack_level too large with capture_output() as out: other_run() assert_equal(out[0], "[<top_level>] function other_run()\n") # Will be executed by nosetests upon importing with capture_output() as out: log("message from no function") assert_equal(out[0], "[<module>] message from no function\n")