1
1
from unittest import TestCase , skip
2
+ from unittest2 .compatibility import wraps
2
3
from pjon_python import base_client
3
4
4
5
import time
5
6
import platform
7
+ import logging
8
+ log = logging .getLogger ("tests" )
6
9
7
- def skipIf (condition , reason ):
8
- if condition :
9
- return skip (reason )
10
- return _id
10
+
11
+ def skipIfCondition (condition , reason ):
12
+ def deco (f ):
13
+ @wraps (f )
14
+ def wrapper (self , * args , ** kwargs ):
15
+ if condition :
16
+ skip (reason )
17
+ else :
18
+ f (self , * args , ** kwargs )
19
+ return wrapper
20
+ return deco
11
21
12
22
13
23
class TestPjonBaseClient (TestCase ):
14
24
def setUp (self ):
25
+ self .is_arm = True if platform .platform ().find ('armv' ) > 0 else False
15
26
self .cli_1 = base_client .PjonBaseSerialClient (bus_addr = 1 , com_port = 'fakeserial' )
16
27
self .cli_1 .start_client ()
17
28
self .cli_2 = base_client .PjonBaseSerialClient (bus_addr = 2 , com_port = 'fakeserial' )
@@ -25,7 +36,7 @@ def test_fake_serial_should_pass_messages_between_clients_no_ack(self):
25
36
time .sleep (.4 )
26
37
self .assertEquals (2 , len (self .cli_2 ._protocol ._stored_received_packets ))
27
38
28
- @skipIf (platform .platform ().find ('armv7' ) , 'skipping on ARM due to performance' )
39
+ @skipIfCondition (platform .platform ().find ('armv' ) > 0 , 'skipping on ARM due to performance' )
29
40
def test_fake_serial_should_pass_messages_between_clients_with_ack (self ):
30
41
self .cli_1 .send (2 , 'test1' )
31
42
self .cli_1 .send (2 , 'test2' )
0 commit comments