def test_two_way(): def test_asserts(f, *args, **kwargs): try: f(*args, **kwargs) except AssertionError: return raise AssertionError # test internal asserts don't false positive t = Voting.TwoWay({1: 2, 3: 4}) t2 = Voting.TwoWay({1: 2, 2: 1, 4: 3}) assert t == t2 # test an invalid dict cannot be made test_asserts(Voting.TwoWay, {1: 2, 2: 3}) def ta2(): t = Voting.TwoWay() t[1] = 2 t[2] = 3 test_asserts(ta2)
def ta2(): t = Voting.TwoWay() t[1] = 2 t[2] = 3 test_asserts(ta2)