Issue 25673: unittest assertLessEqual not working properly with lists (original) (raw)

Created on 2015-11-19 18:34 by kehlert, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
example.py kehlert,2015-11-19 18:34
Messages (2)
msg254920 - (view) Author: (kehlert) Date: 2015-11-19 18:34
I attached a file that explains the issue. Basically, assertLessEqual only seems to compare the first elements of the two lists and ignores the others. Thus a test can pass when it shouldn't.
msg254922 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2015-11-19 18:44
This is how comparison works for sequences and it's not a bug: >>> a = [1, 2] >>> b = [2, 1] >>> a <= b True >>> a = [2, 1] >>> b = [1, 2] >>> a <= b False See https://docs.python.org/3/tutorial/datastructures.html#comparing-sequences-and-other-types
History
Date User Action Args
2022-04-11 14:58:24 admin set github: 69859
2015-11-19 18:44:14 ezio.melotti set status: open -> closedtype: behaviornosy: + ezio.melottimessages: + resolution: not a bugstage: resolved
2015-11-19 18:34:52 kehlert create