diff options
author | JCTutorius <charlie@tutorius-dev.(none)> | 2009-11-06 05:12:01 (GMT) |
---|---|---|
committer | JCTutorius <charlie@tutorius-dev.(none)> | 2009-11-06 05:12:01 (GMT) |
commit | db6d6336b14389301c41f63d50460350646b1d24 (patch) | |
tree | aae1e9f452fba9b6dedb0bbb0d8b4ccb4ee3890e /tests/vaulttests.py | |
parent | 7aad5a2f6a93ae3385794f94f8b175c243165532 (diff) |
Fixed bug that deleted tutorials while executing vault tests.
Diffstat (limited to 'tests/vaulttests.py')
-rw-r--r-- | tests/vaulttests.py | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/tests/vaulttests.py b/tests/vaulttests.py index e45adcb..103414e 100644 --- a/tests/vaulttests.py +++ b/tests/vaulttests.py @@ -61,8 +61,10 @@ class VaultInterfaceTest(unittest.TestCase): ini_file.write('org.laptop.Writus = 1\n') ini_file.close() - def setUp(self): + self.__home = os.getenv("HOME") + # Create a temp vault path so to not add trash data to the real vault + os.environ["HOME"] = os.path.join(os.getenv("HOME"), 'temp_vault_tests') os.environ["SUGAR_BUNDLE_PATH"] = os.path.join(sugar.tutorius.vault._get_store_root(), 'test_bundle_path') path = os.path.join(sugar.tutorius.vault._get_store_root(), 'test_bundle_path', 'data', 'tutorius', 'data') if os.path.isdir(path) != True: @@ -387,7 +389,7 @@ class VaultInterfaceTest(unittest.TestCase): - def tearDown(self): + def tearDown(self): folder = os.path.join(os.getenv("HOME"),".sugar", 'default', 'tutorius', 'data'); for file in os.listdir(folder): file_path = os.path.join(folder, file) @@ -395,6 +397,9 @@ class VaultInterfaceTest(unittest.TestCase): if (os.path.isdir(os.path.join(os.getenv("HOME"),".sugar", 'default', 'tutorius', 'tmp'))): shutil.rmtree(os.path.join(os.getenv("HOME"),".sugar", 'default', 'tutorius', 'tmp')) + + # Restore home env variable to true value + os.environ["HOME"] = self.__home class SerializerInterfaceTest(unittest.TestCase): @@ -424,8 +429,13 @@ class XMLSerializerTest(unittest.TestCase): """ Tests the transformation of XML to FSM, then back. """ + def setUp(self): + self.__home = os.getenv("HOME") + # Create a temp vault path so to not add trash data to the real vault + os.environ["HOME"] = os.path.join(os.getenv("HOME"), 'temp_vault_tests') + # Create the sample FSM self.fsm = Tutorial("TestTutorial1") @@ -441,10 +451,8 @@ class XMLSerializerTest(unittest.TestCase): self.uuid = uuid1() def tearDown(self): - """ - Nothing to do anymore. - """ - pass + # Restore home env variable to true value + os.environ["HOME"] = self.__home def create_test_metadata(self, file_obj, guid): file_obj.write("[GENERAL_METADATA]\n") @@ -541,6 +549,10 @@ class TutorialBundlerTests(unittest.TestCase): """ def setUp(self): + self.__home = os.getenv("HOME") + # Create a temp vault path so to not add trash data to the real vault + os.environ["HOME"] = os.path.join(os.getenv("HOME"), 'temp_vault_tests') + os.environ["SUGAR_BUNDLE_PATH"] = os.path.join(sugar.tutorius.vault._get_store_root(), 'test_bundle_path') path = os.path.join(sugar.tutorius.vault._get_store_root(), 'test_bundle_path') if os.path.isdir(path) != True: @@ -575,6 +587,9 @@ class TutorialBundlerTests(unittest.TestCase): for file in os.listdir(folder): file_path = os.path.join(folder, file) shutil.rmtree(file_path) + + # Restore home env variable to true value + os.environ["HOME"] = self.__home if __name__ == "__main__": |