This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: unittest assertLessEqual not working properly with lists
Type: behavior Stage: resolved
Components: Versions: Python 3.4
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: ezio.melotti, kehlert
Priority: normal Keywords:

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:24adminsetgithub: 69859
2015-11-19 18:44:14ezio.melottisetstatus: open -> closed

type: behavior

nosy: + ezio.melotti
messages: + msg254922
resolution: not a bug
stage: resolved
2015-11-19 18:34:52kehlertcreate