clean up tmp test files in the end

svn: r22983
This commit is contained in:
Vassilii Khachaturov 2013-09-01 07:37:58 +00:00
parent 7b4b9d09f0
commit 7eb11077c8
2 changed files with 22 additions and 5 deletions

View File

@ -43,11 +43,22 @@ out_ged = os.path.join(ddir,"test_out.ged")
class Test(unittest.TestCase):
def setUp(self):
if not os.path.exists(min1r):
open(min1r,"wb").write(test_ged)
self.tearDown()
def tearDown(self):
if os.path.exists(out_ged):
os.remove(out_ged)
@classmethod
def setUpClass(cls):
if not os.path.exists(min1r):
open(min1r,"wb").write(test_ged)
@classmethod
def tearDownClass(cls):
if os.path.exists(min1r):
os.remove(min1r)
# silly test just to illustrate unittest setUp behavior
def test1_setup_works(self):
self.assertTrue(os.path.exists(ddir), "data dir %r exists" % ddir)

View File

@ -23,6 +23,7 @@
""" Unittest for config.py """
import os
import unittest
from ..config import ConfigManager
@ -33,10 +34,15 @@ def callback(*args):
self = args[0]
self._x = args[2]
TEMP_INI = "./temp.ini"
TEST2_INI = "./test2.ini"
class CompleteCheck(unittest.TestCase):
def tearDown(self):
os.remove(TEMP_INI)
os.remove(TEST2_INI)
def testAll(self):
self.CM = ConfigManager("./temp.ini")
self.CM = ConfigManager(TEMP_INI)
self.CM.register("section.setting1", 1) # int
self.CM.register("section.setting2", 3.1415) # float
self.CM.register("section.setting3", "String") # string
@ -115,7 +121,7 @@ class CompleteCheck(unittest.TestCase):
self.CM.register("section2.dict", {'a': "apple", "b": "banana"})
self.CM.register("section2.unicode", "Raötröme")
self.CM.save("./test2.ini")
self.CM.save(TEST2_INI)
self.CM.reset()
self.assertEqual(self.CM.get("section.setting1"), 1, self.CM.get("section.setting1"))
@ -123,7 +129,7 @@ class CompleteCheck(unittest.TestCase):
self.assertEqual(self.CM.get("section.setting3"), "String")
self.assertFalse(self.CM.get("section.setting4"))
self.CM.load("./test2.ini")
self.CM.load(TEST2_INI)
self.assertEqual(self.CM.get("section.setting1"), 2, self.CM.get("section.setting1"))
self.assertEqual(self.CM.get("section.setting2"), 8.6)