def skip_if_env_set(key: str) -> T.Callable[[T.Callable[P, R]], T.Callable[P, R]]:
    '''
    Skip a test if a particular env is set, except when running under CI
    '''
    def wrapper(func: T.Callable[P, R]) -> T.Callable[P, R]:
        @functools.wraps(func)
        def wrapped(*args: P.args, **kwargs: P.kwargs) -> R:
            if key in os.environ and not is_ci():
                raise unittest.SkipTest(f'Env var {key!r} set, skipping')
            with mock.patch.dict(os.environ):
                os.environ.pop(key, None)
                return func(*args, **kwargs)
        return wrapped
    return wrapper

    Skip a test if a particular env is set, except when running under CI
    
unittests/helpers.py