示例#1
0
 def test_line_num1(self):
     '''
     It tests the function line_num
     '''
     import os
     file_name = "test_col.col"
     with open(file_name, "w") as file:
         file.write("var1\n")
         file.write("var3\n")
     i = line_num(file_name, 'var1')
     j = line_num(file_name, 'var3')
     self.assertEqual(i, 1)
     self.assertEqual(j, 2)
示例#2
0
 def test_line_num2(self):
     '''
     It tests an exception error when file does not include target
     '''
     import os
     file_name = "test_col.col"
     with open(file_name, "w") as file:
         file.write("var1\n")
         file.write("var3\n")
     with self.assertRaises(Exception) as context:
         i = line_num(file_name, 'var2')
     self.assertTrue(
         'test_col.col does not include var2' in str(context.exception))