def test_basic(total, maxval): result = list(magic_tuples(total,maxval)) assert all([t[0] <= maxval and t[1] <= maxval for t in result]) assert all([sum(t) == total for t in result])
def test_zeroes(): assert list(magic_tuples(0, 0)) == []
def test_impossible(): result = list(magic_tuples(100, 3)) assert len(result) == 0
def test_is_iterator(): result = magic_tuples(10, 10) assert iter(result) == result