image/fake: added teardown method

Unit tests may alter images in FakeImageService which has pre-defined images.
Since some unit tests depend on those images, so it needs to be cleaned up
after image alternation. Otherwise running many unit tests may fail.
This commit is contained in:
Isaku Yamahata
2011-07-08 18:35:01 +09:00
parent ffd7a4bbe6
commit 81c3ec8328

View File

@@ -31,6 +31,7 @@ import unittest
import mox
import nose.plugins.skip
import nova.image.fake
import shutil
import stubout
from eventlet import greenthread
@@ -119,6 +120,9 @@ class TestCase(unittest.TestCase):
if hasattr(fake.FakeConnection, '_instance'):
del fake.FakeConnection._instance
if FLAGS.image_service == 'nova.image.fake.FakeImageService':
nova.image.fake.FakeImageService_reset()
# Reset any overriden flags
self.reset_flags()