bbk
bbk

Reputation: 229

List of List Comparisons fails

I have got some data from DB in List of List format which i am comparing with the Table displayed in UI. I Extracted UI Tables data into List of List and comparing DB vs UI. Here is the result.

KEYWORD Collections . Lists Should Be Equal ${DataFromDB}, ${DataFromUI}
Documentation:  
Fails if given lists are unequal.

Start / End / Elapsed:  20180306 22:33:28.245 / 20180306 22:33:28.245 / 00:00:00.000
22:33:28.245    FAIL    Lists are different:
Index 0: ('3/6/2018', '16', '8', '50.00', '3024', '841', '27.81') != [u'3/6/2018', u'16', u'8', u'50.00', u'3024', u'841', u'27.81']
Index 1: ('3/5/2018', '16', '9', '56.25', '3024', '2114', '69.91') != [u'3/5/2018', u'16', u'9', u'56.25', u'3024', u'2114', u'69.91']
Index 2: ('3/4/2018', '16', '9', '56.25', '3024', '2224', '73.54') != [u'3/4/2018', u'16', u'9', u'56.25', u'3024', u'2224', u'73.54']
Index 3: ('3/3/2018', '16', '9', '56.25', '3024', '2132', '70.5') != [u'3/3/2018', u'16', u'9', u'56.25', u'3024', u'2132', u'70.50']
Index 4: ('3/2/2018', '16', '9', '56.25', '3024', '2112', '69.84') != [u'3/2/2018', u'16', u'9', u'56.25', u'3024', u'2112', u'69.84']
Index 5: ('3/1/2018', '16', '9', '56.25', '3024', '2112', '69.84') != [u'3/1/2018', u'16', u'9', u'56.25', u'3024', u'2112', u'69.84']
Index 6: ('2/28/2018', '16', '9', '56.25', '3024', '2112', '69.84') != [u'2/28/2018', u'16', u'9', u'56.25', u'3024', u'2112', u'69.84']
Index 7: ('2/27/2018', '16', '9', '56.25', '3024', '2112', '69.84') != [u'2/27/2018', u'16', u'9', u'56.25', u'3024', u'2112', u'69.84']

Though Values are same. But List should Be Equal function is failing..

Not sure if this is due to because of letter 'u' in the list from UI.

Can any one tell what could have went wrong.?

Edit:

Also from RF doc {For example, Python tuple and list with same content are considered equal.} not sure why "Lists Should Be Equal" Keyword failing

Upvotes: 0

Views: 58

Answers (1)

Anthony
Anthony

Reputation: 419

You are comparing tuple to a list. Change your first () to [] and it would work.

a = ['3/6/2018', '16', '8', '50.00', '3024', '841', '27.81']
b = [u'3/6/2018', u'16', u'8', u'50.00', u'3024', u'841', u'27.81']
a1 = ('3/6/2018', '16', '8', '50.00', '3024', '841', '27.81')
print('List to list: ',a == b)
print('Tuple to list:',a1 == b) #your current tuple to list comparison  

Output:

List to list:  True
Tuple to list: False

Note

how to convert tuple to list

If this ('3/6/2018', '16', '8', '50.00', '3024', '841', '27.81') is your entry, then just pass it to list() function - it will take care of it. Here are more examples.

Upvotes: 1

Related Questions