Skip to content

Commit f9d2f2b

Browse files
committed
fixed skipIfCondition decorator
1 parent 888e4aa commit f9d2f2b

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

requirements-dev.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
mock
2+
nose
3+
pyserial >= 3.1.1
4+
unittest2

tests/test_pjonBaseClient.py

+16-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
11
from unittest import TestCase, skip
2+
from unittest2.compatibility import wraps
23
from pjon_python import base_client
34

45
import time
56
import platform
7+
import logging
8+
log = logging.getLogger("tests")
69

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
1121

1222

1323
class TestPjonBaseClient(TestCase):
1424
def setUp(self):
25+
self.is_arm = True if platform.platform().find('armv') > 0 else False
1526
self.cli_1 = base_client.PjonBaseSerialClient(bus_addr=1, com_port='fakeserial')
1627
self.cli_1.start_client()
1728
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):
2536
time.sleep(.4)
2637
self.assertEquals(2, len(self.cli_2._protocol._stored_received_packets))
2738

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')
2940
def test_fake_serial_should_pass_messages_between_clients_with_ack(self):
3041
self.cli_1.send(2, 'test1')
3142
self.cli_1.send(2, 'test2')

0 commit comments

Comments
 (0)