From da26531c87978f56ae2b3ef7e4be543f56eab334 Mon Sep 17 00:00:00 2001 From: hugovk Date: Thu, 8 Jan 2015 11:14:40 +0200 Subject: [PATCH] Skip if PYLAST_USERNAME etc. env vars missing --- tests/test_pylast.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/test_pylast.py b/tests/test_pylast.py index 36f5c60..37695bf 100755 --- a/tests/test_pylast.py +++ b/tests/test_pylast.py @@ -3,6 +3,7 @@ Integration (not unit) tests for pylast.py """ import os +import pytest from random import choice import sys import time @@ -19,10 +20,13 @@ def load_secrets(): doc = yaml.load(f) else: doc = {} - doc["username"] = os.environ['PYLAST_USERNAME'].strip() - doc["password_hash"] = os.environ['PYLAST_PASSWORD_HASH'].strip() - doc["api_key"] = os.environ['PYLAST_API_KEY'].strip() - doc["api_secret"] = os.environ['PYLAST_API_SECRET'].strip() + try: + doc["username"] = os.environ['PYLAST_USERNAME'].strip() + doc["password_hash"] = os.environ['PYLAST_PASSWORD_HASH'].strip() + doc["api_key"] = os.environ['PYLAST_API_KEY'].strip() + doc["api_secret"] = os.environ['PYLAST_API_SECRET'].strip() + except KeyError: + pytest.skip("Missing environment variables: PYLAST_USERNAME etc.") return doc