[TIP] Which is the proper way to test an "unordered list"

Jorge Vargas jorge.vargas at gmail.com
Wed May 16 18:30:38 PDT 2012


I wrote this tiny decorator which is a simple marker. kind of like
@exposed if you do webdev. all it does is validate and create a list
of possible "next_states".

def test_next_two():
    @next("a state")
    @next("another state")
    def a_transition():
    assert a_transition.next_states == ["a state","another state"]

The test above is failing due to the list being reversed.

Of course the simple answer is to flip the values of the static list but...

My question is which will be the proper way to test for this when the
"order of the list" is not valid?

More information about the testing-in-python mailing list