capture stdout in python test [only for python3]
parent
7c53235fdb
commit
83cbcd0bea
|
|
@ -4,6 +4,8 @@ Author: Jing Wu and Frank Dellaert
|
||||||
"""
|
"""
|
||||||
# pylint: disable=invalid-name
|
# pylint: disable=invalid-name
|
||||||
|
|
||||||
|
import io
|
||||||
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
@ -37,6 +39,14 @@ class TestOptimizeComet(GtsamTestCase):
|
||||||
self.optimizer = gtsam.GaussNewtonOptimizer(
|
self.optimizer = gtsam.GaussNewtonOptimizer(
|
||||||
graph, initial, self.params)
|
graph, initial, self.params)
|
||||||
|
|
||||||
|
# setup output capture
|
||||||
|
self.capturedOutput = io.StringIO()
|
||||||
|
sys.stdout = self.capturedOutput
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
"""Reset print capture."""
|
||||||
|
sys.stdout = sys.__stdout__
|
||||||
|
|
||||||
def test_simple_printing(self):
|
def test_simple_printing(self):
|
||||||
"""Test with a simple hook."""
|
"""Test with a simple hook."""
|
||||||
|
|
||||||
|
|
@ -76,4 +86,4 @@ class TestOptimizeComet(GtsamTestCase):
|
||||||
self.gtsamAssertEquals(actual.atRot3(KEY), self.expected)
|
self.gtsamAssertEquals(actual.atRot3(KEY), self.expected)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue