MCPcopy Index your code
hub / github.com/RustPython/RustPython / testBCM

Method testBCM

Lib/test/test_socket.py:2329–2356  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2327 @unittest.skipUnless(hasattr(socket, "CAN_BCM"),
2328 'socket.CAN_BCM required for this test.')
2329 def testBCM(self):
2330 bcm = socket.socket(socket.PF_CAN, socket.SOCK_DGRAM, socket.CAN_BCM)
2331 self.addCleanup(bcm.close)
2332 bcm.connect((self.interface,))
2333 self.can_id = 0x123
2334 self.data = bytes([0xc0, 0xff, 0xee])
2335 self.cf = self.build_can_frame(self.can_id, self.data)
2336 opcode = socket.CAN_BCM_TX_SEND
2337 flags = 0
2338 count = 0
2339 ival1_seconds = ival1_usec = ival2_seconds = ival2_usec = 0
2340 bcm_can_id = 0x0222
2341 nframes = 1
2342 assert len(self.cf) == 16
2343 header = struct.pack(self.bcm_cmd_msg_fmt,
2344 opcode,
2345 flags,
2346 count,
2347 ival1_seconds,
2348 ival1_usec,
2349 ival2_seconds,
2350 ival2_usec,
2351 bcm_can_id,
2352 nframes,
2353 )
2354 header_plus_frame = header + self.cf
2355 bytes_sent = bcm.send(header_plus_frame)
2356 self.assertEqual(bytes_sent, len(header_plus_frame))
2357
2358
2359@unittest.skipUnless(HAVE_SOCKET_CAN_ISOTP, 'CAN ISOTP required for this test.')

Callers

nothing calls this directly

Calls 8

build_can_frameMethod · 0.95
lenFunction · 0.85
socketMethod · 0.80
addCleanupMethod · 0.80
connectMethod · 0.45
packMethod · 0.45
sendMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected