def test_run_with_sec_error(self, llc, error): llc.mac.exchange.side_effect = [error] with pytest.raises(SystemExit): llc.run_as_target() assert llc.mac.exchange.mock_calls == [ mock.call(None, 0.11), ]
def test_run_with_sec_error(self, llc, error): llc.mac.exchange.side_effect = [error] with pytest.raises(SystemExit): llc.run_as_target() assert llc.mac.exchange.mock_calls == [ mock.call(None, 0.11), ]
def test_run_with_remote_terminate(self, llc): llc.mac.exchange.side_effect = [HEX('0000'), HEX('0140')] llc.run_as_target() assert llc.mac.exchange.mock_calls == [ mock.call(None, 0.11), mock.call(HEX('0000'), 0.11), ]
def test_run_with_remote_terminate(self, llc): llc.mac.exchange.side_effect = [HEX('0000'), HEX('0140')] llc.run_as_target() assert llc.mac.exchange.mock_calls == [ mock.call(None, 0.11), mock.call(HEX('0000'), 0.11), ]
def test_run_with_io_error(self, llc): llc.mac.exchange.side_effect = [HEX('0000'), IOError] with pytest.raises(SystemExit): llc.run_as_target() assert llc.mac.exchange.mock_calls == [ mock.call(None, 0.11), mock.call(HEX('0000'), 0.11), ]
def test_run_with_io_error(self, llc): llc.mac.exchange.side_effect = [HEX('0000'), IOError] with pytest.raises(SystemExit): llc.run_as_target() assert llc.mac.exchange.mock_calls == [ mock.call(None, 0.11), mock.call(HEX('0000'), 0.11), ]
def test_run_with_kbd_interrupt(self, llc): llc.mac.exchange.side_effect \ = [HEX('0000'), KeyboardInterrupt] with pytest.raises(KeyboardInterrupt): llc.run_as_target() assert llc.mac.exchange.mock_calls == [ mock.call(None, 0.11), mock.call(HEX('0000'), 0.11), ]
def test_run_with_kbd_interrupt(self, llc): llc.mac.exchange.side_effect \ = [HEX('0000'), KeyboardInterrupt] with pytest.raises(KeyboardInterrupt): llc.run_as_target() assert llc.mac.exchange.mock_calls == [ mock.call(None, 0.11), mock.call(HEX('0000'), 0.11), ]
def test_run_send_pdu_and_symm(self, llc, ldl): llc.mac.exchange.side_effect = 10 * [HEX('0000')] + [None] llc.sendto(ldl, b'123', 16, nfc.llcp.MSG_DONTWAIT) llc.run_as_target() print(llc.mac.exchange.mock_calls) assert llc.mac.exchange.mock_calls == [ mock.call(None, 0.11), mock.call(HEX('40e0313233'), 0.11), ] + 9 * [mock.call(HEX('0000'), 0.11)] assert str(llc.pcnt) == "sent/rcvd 10/10 SYMM 9/10 UI 1/0"
def test_run_send_pdu_and_symm(self, llc, ldl): llc.mac.exchange.side_effect = 10 * [HEX('0000')] + [None] llc.sendto(ldl, b'123', 16, nfc.llcp.MSG_DONTWAIT) llc.run_as_target() print(llc.mac.exchange.mock_calls) assert llc.mac.exchange.mock_calls == [ mock.call(None, 0.11), mock.call(HEX('40e0313233'), 0.11), ] + 9 * [ mock.call(HEX('0000'), 0.11) ] assert str(llc.pcnt) == "sent/rcvd 10/10 SYMM 9/10 UI 1/0"
def test_run_with_local_terminate(self, llc): llc.mac.exchange.side_effect = [HEX('0000')] llc.run_as_target(terminate=lambda: True) assert llc.mac.exchange.mock_calls == [ mock.call(None, 0.11), ]
def test_run_with_local_terminate(self, llc): llc.mac.exchange.side_effect = [HEX('0000')] llc.run_as_target(terminate=lambda: True) assert llc.mac.exchange.mock_calls == [ mock.call(None, 0.11), ]