import unittest import utils.file_tool as t import utils.path_tool import basic.program class MyTestCase(unittest.TestCase): def xtest_getFiles(self): job = basic.program.Job("unit") args = {"application": "TEST", "application": "ENV01", "modus": "unit", "loglevel": "debug", "tool": "job_tool", "modus": "unit"} job.par.setParameterArgs(args) r = t.getFiles(job.m, job.conf.confs.get("paths").get("program") + "/utils", "file_.*.py", None) self.assertEqual((len(r) == 1), True) r = t.getFiles(job.m, job.conf.confs.get("paths").get("program") + "/utils", "file__.*.py", None) self.assertEqual((len(r) == 0), True) r = t.getFiles(job.m, job.conf.confs.get("paths").get("program") + "/utils", ".*_tool.py", None) self.assertEqual((len(r) > 2), True) r = t.getFilesRec(job.m, job.conf.confs.get("paths").get("program"), ".*?file.*.py") print (r) def xtest_pathTool(self): job = basic.program.Job("unit") args = {"application": "TEST", "application": "ENV01", "modus": "unit", "loglevel": "debug", "tool": "job_tool", "modus": "unit"} job.par.setParameterArgs(args) #self.assertEqual(utils.path_tool.generatePath("program", "komp", "testA", "CONFIG.yml"), # "/home/basic/6_Projekte/PythonProject/komponents/testA/COFIG.yml") def test_encoding(self): print("------- test_encoding") encodings = ['utf-8', 'windows-1250', 'iso-8859-1'] res = utils.file_tool.getFileEncoding("/home/ulrich/6_Projekte/Programme/holtz/test/tdata/encoded_iso8859.txt") self.assertEqual(res, "iso-8859-1") res = utils.file_tool.getFileEncoding("/home/ulrich/6_Projekte/Programme/holtz/test/tdata/encoded_win1250.txt") self.assertEqual(res, "iso-8859-1") res = utils.file_tool.getFileEncoding("/home/ulrich/6_Projekte/Programme/holtz/test/tdata/encoded_utf8.txt") self.assertEqual(res, "utf-8") if __name__ == '__main__': unittest.main()