Skip to content

Commit c9c96c7

Browse files
committed
Merge pull request #108 from ddemidov/update-tests
Update tests to use the new functionality in fake-sys
2 parents a0c1441 + d60414c commit c9c96c7

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

tests/api_tests.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
#!/usr/bin/env python
22
import unittest, sys, os
33

4+
FAKE_SYS = os.path.join(os.path.dirname(__file__), 'fake-sys')
5+
6+
sys.path.append(FAKE_SYS)
47
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
58

9+
from populate_arena import populate_arena
10+
from clean_arena import clean_arena
11+
612
import ev3dev.ev3 as ev3
713

8-
ev3.Device.DEVICE_ROOT_PATH = os.path.join(os.path.dirname(__file__), 'fake-sys')
14+
ev3.Device.DEVICE_ROOT_PATH = os.path.join(FAKE_SYS, 'arena')
915

1016
class TestAPI(unittest.TestCase):
1117
def test_device(self):
18+
clean_arena()
19+
populate_arena({'medium_motor' : [0, 'outA'], 'infrared_sensor' : [0, 'in1']})
20+
1221
d = ev3.Device('tacho-motor', 'motor*')
1322
self.assertTrue(d.connected)
1423

@@ -31,6 +40,9 @@ def test_medium_motor(self):
3140
def dummy(self):
3241
pass
3342

43+
clean_arena()
44+
populate_arena({'medium_motor' : [0, 'outA']})
45+
3446
# Do not write motor.command on exit (so that fake tree stays intact)
3547
ev3.MediumMotor.__del__ = dummy
3648

@@ -66,6 +78,9 @@ def dummy(self):
6678
c = m.command
6779

6880
def test_infrared_sensor(self):
81+
clean_arena()
82+
populate_arena({'infrared_sensor' : [0, 'in1']})
83+
6984
s = ev3.InfraredSensor()
7085

7186
self.assertTrue(s.connected)

tests/fake-sys

0 commit comments

Comments
 (0)