Reduce default stdout verbosity

Add OPENPHOTO_TEST_DEBUG env var for increased debug output
This commit is contained in:
sneakypete81 2013-05-11 15:28:17 +01:00
parent a2d103ec1a
commit 60c4d98b85
2 changed files with 27 additions and 8 deletions

View file

@ -42,6 +42,10 @@ The easiest way to run a subset of the tests is with nose:
All HTTP requests and responses are recorded in the file "tests.log".
You can enable more verbose output to stdout with the following environment variable:
export OPENPHOTO_TEST_DEBUG=1
---------------------------------------
<a name="test_details"></a>
### Test Details

View file

@ -1,3 +1,4 @@
import sys
import os
import unittest
import logging
@ -13,7 +14,9 @@ class TestBase(unittest.TestCase):
MAXIMUM_TEST_PHOTOS = 4 # Never have more the 4 photos on the test server
testcase_name = "(unknown testcase)"
api_version = None
config_file = os.getenv("OPENPHOTO_TEST_CONFIG", "test")
debug = (os.getenv("OPENPHOTO_TEST_DEBUG", "0") == "1")
def __init__(self, *args, **kwds):
unittest.TestCase.__init__(self, *args, **kwds)
@ -27,10 +30,11 @@ class TestBase(unittest.TestCase):
@classmethod
def setUpClass(cls):
""" Ensure there is nothing on the server before running any tests """
if cls.api_version is None:
print "\nTesting Latest %s" % cls.testcase_name
else:
print "\nTesting %s v%d" % (cls.testcase_name, cls.api_version)
if cls.debug:
if cls.api_version is None:
print "\nTesting Latest %s" % cls.testcase_name
else:
print "\nTesting %s v%d" % (cls.testcase_name, cls.api_version)
cls.client = openphoto.OpenPhoto(config_file=cls.config_file,
api_version=cls.api_version)
@ -63,8 +67,11 @@ class TestBase(unittest.TestCase):
"""
self.photos = self.client.photos.list()
if len(self.photos) != 3:
# print self.photos
print "[Regenerating Photos]"
if self.debug:
print "[Regenerating Photos]"
else:
print " ",
sys.stdout.flush()
if len(self.photos) > 0:
self._delete_all()
self._create_test_photos()
@ -74,7 +81,11 @@ class TestBase(unittest.TestCase):
if (len(self.tags) != 1 or
self.tags[0].id != self.TEST_TAG or
str(self.tags[0].count) != "3"):
print "[Regenerating Tags]"
if self.debug:
print "[Regenerating Tags]"
else:
print " ",
sys.stdout.flush()
self._delete_all()
self._create_test_photos()
self.photos = self.client.photos.list()
@ -87,7 +98,11 @@ class TestBase(unittest.TestCase):
if (len(self.albums) != 1 or
self.albums[0].name != self.TEST_ALBUM or
self.albums[0].count != "3"):
print "[Regenerating Albums]"
if self.debug:
print "[Regenerating Albums]"
else:
print " ",
sys.stdout.flush()
self._delete_all()
self._create_test_photos()
self.photos = self.client.photos.list()