4 # Copyright (C) 2010-2018 CEA/DEN
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 import initializeTest # set PATH etc for test
26 import src.debug as DBG # Easy print stderr (for DEBUG only)
27 import src.pyconf as PYF # 0.3.7
34 stream : "sys.stderr" # modified
35 message: 111 # modified
39 stream : $messages[0].stream
40 message: 1.23e4 # modified do not work 0.3.7
44 stream : "HELLO " + $messages[0].stream
58 bb: "Herve" # avoid Hervé -> 'utf8' codec can't decode byte
63 bb: "Hervé" # avoid Hervé -> 'utf8' codec can't decode byte
70 class TestCase(unittest.TestCase):
74 # one shot setUp() for this TestCase
75 # DBG.push_debug(True)
76 # SAT.setNotLocale() # test english
80 res = DBG.getLocalEnv()
81 self.assertTrue(len(res.split()) > 0)
82 self.assertTrue("USER :" in res)
83 self.assertTrue("LANG :" in res)
86 inStream = DBG.InStream(_EXAMPLES[1])
87 self.assertEqual(inStream.getvalue(), _EXAMPLES[1])
88 cfg = PYF.Config(inStream)
89 self.assertEqual(len(cfg.messages), 3)
90 outStream = DBG.OutStream()
91 DBG.saveConfigStd(cfg, outStream)
93 DBG.write("test_010 cfg std", res)
94 self.assertTrue("messages :" in res)
95 self.assertTrue("'sys.stderr'" in res)
98 inStream = DBG.InStream(_EXAMPLES[2])
99 cfg = PYF.Config(inStream)
100 res = DBG.getStrConfigDbg(cfg)
101 DBG.write("test_020 cfg dbg", res)
102 ress = res.split("\n")
103 self.assertTrue(".aa" in ress[0])
104 self.assertTrue(": '111'" in ress[0])
105 self.assertTrue(".bb" in ress[1])
106 self.assertTrue(": $aa + 222 " in ress[1])
107 self.assertTrue("--> '333'" in ress[1])
110 inStream = DBG.InStream(_EXAMPLES[1])
111 cfg = PYF.Config(inStream)
112 outStream = DBG.OutStream()
113 DBG.saveConfigDbg(cfg, outStream)
114 res = outStream.value
115 DBG.write("test_025 cfg dbg", res)
116 for i in range(len(cfg.messages)):
117 self.assertTrue("messages[%i].name" % i in res)
118 self.assertTrue("--> 'HELLO sys.stderr'" in res)
122 # one shot tearDown() for this TestCase
123 # SAT.setLocale() # end test english
127 if __name__ == '__main__':
128 unittest.main(exit=False)