Skip to content

Commit

Permalink
dictionary must be sorted for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
nehpetsde committed Apr 3, 2017
1 parent 99c3794 commit fd522b7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/nfc/clf/rcs380.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def tg_set_protocol(self, data=None, **kwargs):
data = bytearray() if data is None else bytearray(data)
KEYS = ("send_timeout_time_unit", "rf_off_error",
"continuous_receive_mode")
for key, value in kwargs.iteritems():
for key, value in sorted(kwargs.iteritems()):
data.extend(bytearray([KEYS.index(key), int(value)]))
data = self.send_command(0x42, bytearray(data))
if data and data[0] != 0:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_clf_rcs380.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,17 +306,17 @@ def test_tg_set_rf(self, chipset, comm_type, command):
assert excinfo.value.errno == 1

@pytest.mark.parametrize("data, kwargs, command", [
(None, {}, ''),
(None, {}, None),
(None, {"send_timeout_time_unit": 255}, '4200ff'),
(None, {"rf_off_error": 255}, '4201ff'),
(None, {"continuous_receive_mode": 255}, '4202ff'),
(b'1', {"send_timeout_time_unit": 254, "rf_off_error": 255},
'423100fe01ff'),
'423101ff00fe'),
])
def test_tg_set_protocol(self, chipset, data, kwargs, command):
chipset.transport.read.side_effect = [ACK(), RSP('4300')]
assert chipset.tg_set_protocol(data, **kwargs) is None
if len(command) > 0:
if command:
chipset.transport.write.assert_called_with(CMD(command))
chipset.transport.read.side_effect = [ACK(), RSP('4301')]
with pytest.raises(nfc.clf.rcs380.StatusError) as excinfo:
Expand Down

0 comments on commit fd522b7

Please sign in to comment.