def test_invalid_typevar_bound(bound): T = TypeVar('T', bound=bound) pytest.raises_regexp(ValueError, 'invalid typevar bound', Handler, T)