Skip to content

Commit

Permalink
Slight modification of mock imports to make them work
Browse files Browse the repository at this point in the history
fix one test that failed to release the lock - this blocked the follow on tests
  • Loading branch information
imcleod committed Apr 2, 2014
1 parent 3f2d0d9 commit 36f8118
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tests/test_cacheManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
from tests.MockOS import MockOS

# Force CacheManager to use MockStackEnvironment
sys.path.append("../")
import MockStackEnvironment
sys.modules['StackEnvironment'] = sys.modules.pop('MockStackEnvironment')
sys.modules['StackEnvironment'] = sys.modules.pop('tests.MockStackEnvironment')
sys.modules['StackEnvironment'].StackEnvironment = sys.modules['StackEnvironment'].MockStackEnvironment
import StackEnvironment
import novaimagebuilder.CacheManager
Expand All @@ -49,6 +50,7 @@ def test_lock_and_get_index(self):
self.cache_mgr.lock_and_get_index()
self.assertIsNotNone(self.cache_mgr.index)
self.assertIsInstance(self.cache_mgr.index, dict)
self.cache_mgr.unlock_index()

def test_write_index_and_unlock(self):
self.cache_mgr.lock_and_get_index()
Expand Down Expand Up @@ -83,4 +85,4 @@ def test_retrieve_and_cache_object(self):
del self.cache_mgr.index['%s-%s' % (self.os_dict['shortid'], self.install_config['arch'])]
self.cache_mgr.write_index_and_unlock()
except KeyError:
pass
pass

1 comment on commit 36f8118

@steveloranz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be dependent on what test runner is being used. Using python unittest instead of nose works without having to append "../" or specify "tests."

Please sign in to comment.