def set_alignment_method(alignment, method): try: alignment_i = get_alignments().index(alignment) except ValueError: raise ValueError("Unknown alignment %r" % (alignment,)) try: method_i = get_methods().index(method) except ValueError: raise ValueError("Unknown method %r" % (method,)) _chemfp.set_alignment_method(alignment_i, method_i)
def test_internal_bad_args(self): with self.assertRaisesRegexp(IndexError, "alignment index is out of range"): _chemfp.get_alignment_name(-1) with self.assertRaisesRegexp(IndexError, "alignment index is out of range"): _chemfp.get_alignment_name(_chemfp.get_num_methods()) # I didn't want a better error code for this with self.assertRaisesRegexp(ValueError, "Bad argument"): _chemfp.get_alignment_name(_chemfp.get_alignment_method(-1)) with self.assertRaisesRegexp(ValueError, "Bad argument"): _chemfp.get_alignment_name(_chemfp.get_alignment_method(100)) with self.assertRaisesRegexp(ValueError, "Bad argument"): _chemfp.get_alignment_name(_chemfp.set_alignment_method(-1, 0)) with self.assertRaisesRegexp(ValueError, "Bad argument"): _chemfp.get_alignment_name(_chemfp.set_alignment_method(100, 0))