clean up tmp test files in the end
svn: r22983
This commit is contained in:
parent
7b4b9d09f0
commit
7eb11077c8
@ -43,11 +43,22 @@ out_ged = os.path.join(ddir,"test_out.ged")
|
|||||||
|
|
||||||
class Test(unittest.TestCase):
|
class Test(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
if not os.path.exists(min1r):
|
self.tearDown()
|
||||||
open(min1r,"wb").write(test_ged)
|
|
||||||
|
def tearDown(self):
|
||||||
if os.path.exists(out_ged):
|
if os.path.exists(out_ged):
|
||||||
os.remove(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
|
# silly test just to illustrate unittest setUp behavior
|
||||||
def test1_setup_works(self):
|
def test1_setup_works(self):
|
||||||
self.assertTrue(os.path.exists(ddir), "data dir %r exists" % ddir)
|
self.assertTrue(os.path.exists(ddir), "data dir %r exists" % ddir)
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
""" Unittest for config.py """
|
""" Unittest for config.py """
|
||||||
|
|
||||||
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
from ..config import ConfigManager
|
from ..config import ConfigManager
|
||||||
|
|
||||||
@ -33,10 +34,15 @@ def callback(*args):
|
|||||||
self = args[0]
|
self = args[0]
|
||||||
self._x = args[2]
|
self._x = args[2]
|
||||||
|
|
||||||
|
TEMP_INI = "./temp.ini"
|
||||||
|
TEST2_INI = "./test2.ini"
|
||||||
class CompleteCheck(unittest.TestCase):
|
class CompleteCheck(unittest.TestCase):
|
||||||
|
def tearDown(self):
|
||||||
|
os.remove(TEMP_INI)
|
||||||
|
os.remove(TEST2_INI)
|
||||||
|
|
||||||
def testAll(self):
|
def testAll(self):
|
||||||
self.CM = ConfigManager("./temp.ini")
|
self.CM = ConfigManager(TEMP_INI)
|
||||||
self.CM.register("section.setting1", 1) # int
|
self.CM.register("section.setting1", 1) # int
|
||||||
self.CM.register("section.setting2", 3.1415) # float
|
self.CM.register("section.setting2", 3.1415) # float
|
||||||
self.CM.register("section.setting3", "String") # string
|
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.dict", {'a': "apple", "b": "banana"})
|
||||||
self.CM.register("section2.unicode", "Raötröme")
|
self.CM.register("section2.unicode", "Raötröme")
|
||||||
|
|
||||||
self.CM.save("./test2.ini")
|
self.CM.save(TEST2_INI)
|
||||||
self.CM.reset()
|
self.CM.reset()
|
||||||
|
|
||||||
self.assertEqual(self.CM.get("section.setting1"), 1, self.CM.get("section.setting1"))
|
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.assertEqual(self.CM.get("section.setting3"), "String")
|
||||||
self.assertFalse(self.CM.get("section.setting4"))
|
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.setting1"), 2, self.CM.get("section.setting1"))
|
||||||
self.assertEqual(self.CM.get("section.setting2"), 8.6)
|
self.assertEqual(self.CM.get("section.setting2"), 8.6)
|
||||||
|
Loading…
Reference in New Issue
Block a user