Skip to content

Commit 3f8c3b7

Browse files
committed
network_test: Do not modify environment for other tests
Also do not skip the test since there will always be an interface (previously set globally and now prepared in setUp function.
1 parent 9f7cb8c commit 3f8c3b7

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

test/network_test.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414
import can
1515

1616
channel = "vcan0"
17-
can.rc["interface"] = "virtual"
1817

1918

20-
@unittest.skipIf("interface" not in can.rc, "Need a CAN interface")
2119
class ControllerAreaNetworkTestCase(unittest.TestCase):
2220
"""
2321
This test ensures that what messages go in to the bus is what comes out.
@@ -42,6 +40,15 @@ class ControllerAreaNetworkTestCase(unittest.TestCase):
4240
for b in range(num_messages)
4341
)
4442

43+
def setUp(self):
44+
# Save all can.rc defaults
45+
self._can_rc = can.rc
46+
can.rc = {"interface": "virtual"}
47+
48+
def tearDown(self):
49+
# Restore the defaults
50+
can.rc = self._can_rc
51+
4552
def producer(self, ready_event, msg_read):
4653
self.client_bus = can.interface.Bus(channel=channel)
4754
ready_event.wait()

0 commit comments

Comments
 (0)