Skip to content

Commit

Permalink
Move environment variable checks inside the test case constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
ivknv committed Jul 10, 2021
1 parent b18201f commit 2c56a2e
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions tests/resources_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,25 @@
yadisk_async.settings.DEFAULT_N_RETRIES = 50
yadisk_async.settings.DEFAULT_UPLOAD_N_RETRIES = 50

if not os.environ.get("PYTHON_YADISK_APP_TOKEN"):
raise ValueError("Environment variable PYTHON_YADISK_APP_TOKEN must be set")

if not os.environ.get("PYTHON_YADISK_TEST_ROOT"):
raise ValueError("Environment variable PYTHON_YADISK_TEST_ROOT must be set")


def async_test(f):
def wrapper(*args, **kwargs):
loop = asyncio.get_event_loop()
loop.run_until_complete(f(*args, **kwargs))

return wrapper


class ResourcesTestCase(TestCase):
def __init__(self, *args, **kwargs):
self.yadisk = None

TestCase.__init__(self, *args, **kwargs)

if not os.environ.get("PYTHON_YADISK_APP_TOKEN"):
raise ValueError("Environment variable PYTHON_YADISK_APP_TOKEN must be set")

if not os.environ.get("PYTHON_YADISK_TEST_ROOT"):
raise ValueError("Environment variable PYTHON_YADISK_TEST_ROOT must be set")

self.yadisk = yadisk_async.YaDisk(os.environ.get("PYTHON_YADISK_APP_ID"),
os.environ.get("PYTHON_YADISK_APP_SECRET"),
os.environ.get("PYTHON_YADISK_APP_TOKEN"))
Expand Down

0 comments on commit 2c56a2e

Please sign in to comment.