def test_validity(compounds_pair: Tuple[Compound, Compound]) -> None: left_compound, right_compound = compounds_pair result = left_compound - right_compound with not_raises(ValueError): result.validate()
def test_functions(f): if accepts_args(f): with not_raises(TypeError, match=r'.* positional argument.*'): f(1) else: with pytest.raises( TypeError, match=r'.*takes 0 positional arguments but 1 was given.*'): f(1)
def test_methods(method): inst = SomeClass() bound = getattr(inst, method.__name__) if accepts_args(method): with not_raises(TypeError, match=r'.* positional argument.*'): bound(1) else: with pytest.raises( TypeError, match=r'.*takes 1 positional argument but 2 were given.*'): bound(1)