summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2012-12-18 17:25:40 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2012-12-18 17:25:40 +0000
commit4c7b6184fe12775ceb83cefb405921e961495e9c (patch)
tree785a0061407f7c867668ac4ed1f2dbb9d095aed9
parent3171324c2184b185224e29b61a84a9f4134553d5 (diff)
parentf352c4e7804f64a29670c23e50cff3c56a902496 (diff)
downloadmorph-4c7b6184fe12775ceb83cefb405921e961495e9c.tar.gz
Merge branch 'liw/silence-log-messages-during-unit-tests'
-rw-r--r--morphlib/remoteartifactcache.py8
-rw-r--r--morphlib/remoteartifactcache_tests.py6
2 files changed, 8 insertions, 6 deletions
diff --git a/morphlib/remoteartifactcache.py b/morphlib/remoteartifactcache.py
index e50c1159..17f547f2 100644
--- a/morphlib/remoteartifactcache.py
+++ b/morphlib/remoteartifactcache.py
@@ -67,18 +67,18 @@ class RemoteArtifactCache(object):
filename = '%s.%s' % (cachekey, name)
return self._has_file(filename)
- def get(self, artifact):
+ def get(self, artifact, log=logging.error):
try:
return self._get_file(artifact.basename())
except urllib2.URLError, e:
- logging.error(str(e))
+ log(str(e))
raise GetError(self, artifact)
- def get_artifact_metadata(self, artifact, name):
+ def get_artifact_metadata(self, artifact, name, log=logging.error):
try:
return self._get_file(artifact.metadata_basename(name))
except urllib2.URLError, e:
- logging.error(str(e))
+ log(str(e))
raise GetArtifactMetadataError(self, artifact, name)
def get_source_metadata(self, source, cachekey, name):
diff --git a/morphlib/remoteartifactcache_tests.py b/morphlib/remoteartifactcache_tests.py
index a4ec9370..431731b9 100644
--- a/morphlib/remoteartifactcache_tests.py
+++ b/morphlib/remoteartifactcache_tests.py
@@ -123,7 +123,8 @@ class RemoteArtifactCacheTests(unittest.TestCase):
def test_fails_to_get_a_non_existent_artifact(self):
self.assertRaises(morphlib.remoteartifactcache.GetError,
- self.cache.get, self.doc_artifact)
+ self.cache.get, self.doc_artifact,
+ log=lambda *args: None)
def test_get_existing_artifact_metadata(self):
handle = self.cache.get_artifact_metadata(
@@ -137,7 +138,8 @@ class RemoteArtifactCacheTests(unittest.TestCase):
morphlib.remoteartifactcache.GetArtifactMetadataError,
self.cache.get_artifact_metadata,
self.runtime_artifact,
- 'non-existent-meta')
+ 'non-existent-meta',
+ log=lambda *args: None)
def test_get_existing_source_metadata(self):
handle = self.cache.get_source_metadata(