File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python3
2
+ # coding: utf-8
3
+
4
+ """
5
+ This module tests the functions inside of player.py
6
+ """
7
+
8
+ import unittest
9
+ from unittest import mock
10
+ from unittest .mock import Mock
11
+ import os
12
+ import sys
13
+ import can
14
+ import can .player
15
+
16
+ from .config import *
17
+
18
+
19
+ class TestPlayerScriptModule (unittest .TestCase ):
20
+ def setUp (self ) -> None :
21
+ # Patch VirtualBus object
22
+ patcher_virtual_bus = mock .patch ("can.interfaces.virtual.VirtualBus" , spec = True )
23
+ self .MockVirtualBus = patcher_virtual_bus .start ()
24
+ self .addCleanup (patcher_virtual_bus .stop )
25
+ self .mock_virtual_bus = self .MockVirtualBus .return_value
26
+ self .mock_virtual_bus .shutdown = Mock ()
27
+
28
+ self .baseargs = [sys .argv [0 ], "-i" , "virtual" ]
29
+ self .logfile = os .path .join (os .path .dirname (__file__ ), "data" , "test_CanMessage.asc" )
30
+
31
+ def assertSuccessfullCleanup (self ):
32
+ self .MockVirtualBus .assert_called_once ()
33
+
34
+ def test_play_virtual (self ):
35
+ sys .argv = self .baseargs + [self .logfile ]
36
+ can .player .main ()
37
+ self .assertSuccessfullCleanup ()
38
+
39
+
40
+ if __name__ == "__main__" :
41
+ unittest .main ()
You can’t perform that action at this time.
0 commit comments