"""Tests for the input/output component.""" import unittest import io import sys from imago.engine.imagoIO import ImagoIO class TestImagoIO(unittest.TestCase): """Test ImagoIO component.""" @unittest.mock.patch('imago.engine.imagoIO.input', create=True) def testSimpleCommands(self, mocked_input): """Test simple commands.""" mocked_input.side_effect = [ 'name\n', 'version\n', 'protocol_version\n', 'quit\n' ] testout = io.StringIO() imagoIO = ImagoIO(outputStream=testout) imagoIO.start() value = testout.getvalue() self.assertEqual( '= Imago\n\n' + '= 0.0.0\n\n' + '= 2\n\n', value ) testout.close() if __name__ == '__main__': unittest.main()