confini

Parse and merge multiple ini files in python3
git clone git://git.defalsify.org/python-confini.git
Info | Log | Files | Refs | README | LICENSE

test_translate.py (1033B)


      1 # standard imports
      2 import os
      3 import unittest
      4 import logging
      5 
      6 # local imports
      7 from confini import Config
      8 
      9 logging.basicConfig(level=logging.DEBUG)
     10 logg = logging.getLogger()
     11 
     12 
     13 class TestTranslate(unittest.TestCase):
     14 
     15     wd = os.path.dirname(__file__)
     16 
     17     def setUp(self):
     18         pass
     19 
     20 
     21     def tearDown(self):
     22         pass
     23 
     24 
     25     def test_parse_default(self):
     26         inidir = os.path.join(self.wd, 'files/translate')
     27         c = Config(inidir)
     28         c.process()
     29 
     30         self.assertTrue(c.get('TRUE_A'))
     31         self.assertTrue(c.get('TRUE_B'))
     32         self.assertTrue(c.get('TRUE_C'))
     33 
     34         self.assertFalse(c.true('FALSE_A'))
     35         self.assertFalse(c.true('FALSE_B'))
     36         self.assertFalse(c.true('FALSE_C'))
     37         self.assertIsNone(c.get('FALSE_D'))
     38 
     39         o = {
     40             'TRUE_A': True,
     41             'FALSE_A': False,
     42                 }
     43         c.dict_override(o, 'test')
     44         self.assertTrue(c.true('TRUE_A'))
     45         self.assertFalse(c.true('FALSE_A'))
     46 
     47      
     48 if __name__ == '__main__':
     49     unittest.main()