Skip to content

Commit c41845f

Browse files
committed
Add check for output on screen
1 parent bae496e commit c41845f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

test/test_player.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from unittest.mock import Mock
1111
import os
1212
import sys
13+
import io
1314
import can
1415
import can.player
1516

@@ -48,8 +49,10 @@ def test_play_virtual(self):
4849

4950
def test_play_virtual_verbose(self):
5051
sys.argv = self.baseargs + ["-v", self.logfile]
51-
can.player.main()
52-
# TODO: add test message was printed
52+
with unittest.mock.patch('sys.stdout', new_callable=io.StringIO) as mock_stdout:
53+
can.player.main()
54+
self.assertIn('09 08 07 06 05 04 03 02', mock_stdout.getvalue())
55+
self.assertIn('05 0c 00 00 00 00 00 00', mock_stdout.getvalue())
5356
self.assertEqual(self.mock_virtual_bus.send.call_count, 2)
5457
self.assertEqual(self.MockSleep.call_count, 2)
5558
self.assertSuccessfullCleanup()

0 commit comments

Comments
 (0)