@@ -0,0 +1,1494 @@
+%22%22%22Tests for the basic permutation facility.%0A%22%22%22%0A%0Aimport pickle%0A%0Aimport pytest%0A%0Afrom drudge import Perm%0A%0A%0Adef test_perm_has_basic_functionality():%0A    %22%22%22Test the basic facility for Perms.%0A%0A    Here a simple cyclic permutation of three points is used to test various%0A    facilities of Perm.%0A    %22%22%22%0A%0A    pre_images = %5B1, 2, 0%5D%0A    perm = Perm(pre_images, 1)%0A%0A    assert (len(perm) == len(pre_images))%0A    for i, v in enumerate(pre_images):%0A        assert (perm%5Bi%5D == v)%0A%0A    assert (perm.acc == 1)%0A%0A    return%0A%0A%0Adef test_perm_pickles():%0A    %22%22%22Tests perms can be correctly pickled.%22%22%22%0A%0A    pre_images = %5B1, 2, 0%5D%0A    perm = Perm(pre_images, 1)%0A%0A    new_args = perm.__getnewargs__()%0A    assert (len(new_args) == 2)%0A    assert (new_args%5B0%5D == pre_images)%0A    assert (new_args%5B1%5D == 1)%0A    new_perm = Perm(*new_args)%0A%0A    pickled = pickle.dumps(perm)%0A    unpickled_perm = pickle.loads(pickled)%0A%0A    for form in %5Bnew_perm, unpickled_perm%5D:%0A        # Maybe equality comparison should be added to Perms.%0A        assert (len(form) == len(perm))%0A        for i in range(len(perm)):%0A            assert (form%5Bi%5D == perm%5Bi%5D)%0A        assert (form.acc == perm.acc)%0A%0A    return%0A%0A%0Adef test_perm_reports_error():%0A    %22%22%22Tests perm class reports error for invalid inputs.%22%22%22%0A%0A    with pytest.raises(ValueError):%0A        Perm(%5B1, 1, 1%5D)%0A%0A    with pytest.raises(ValueError):%0A        Perm(%5B1, 2%5D)%0A%0A    with pytest.raises(TypeError):%0A        Perm('aaa')%0A%0A    with pytest.raises(TypeError):%0A        Perm(%5B0, 1%5D, 0.5)%0A

Add tests for Perm