The following unittest fails when running it (with pytest), but when I debug it, it passes:
def test():
assert list(set(['B', 'A'])) == ['A', 'B']
I know that sets have no order, but I don't understand how to determine the result of list(s)
if s
is a set, which is crucial when writing unittests. A workaround mentioned here would be to change the code to sorted(s)
, but I want to understand what happens when list(s)
is run.