Files
Auto-GPT/tests/utils.py
James Collins dcd6aa912b Add workspace abstraction (#2982)
* Add workspace abstraction

* Remove old workspace implementation

* Extract path resolution to a helper function

* Add api key requirements to new tests
2023-04-23 14:36:04 -05:00

28 lines
641 B
Python

import functools
import os
import pytest
def requires_api_key(env_var):
def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
if not os.environ.get(env_var):
pytest.skip(
f"Environment variable '{env_var}' is not set, skipping the test."
)
else:
return func(*args, **kwargs)
return wrapper
return decorator
def skip_in_ci(test_function):
return pytest.mark.skipif(
os.environ.get("CI") == "true",
reason="This test doesn't work on GitHub Actions.",
)(test_function)