示例#1
0
 def test_input_file(self):
     args = self.parser.parse_args(["-f", "setup.py"])
     command = evaluator.CommandLine(self.parser, args)
     self.assertEqual(args.file, command.in_file)
     self.assertIsNone(args.folder)
     self.assertEqual("setup_py.txt", command.out_file)
     self.assertEqual("python", command.language)
示例#2
0
 def test_input_folder(self):
     args = self.parser.parse_args(["-F", "test"])
     command = evaluator.CommandLine(self.parser, args)
     # self.assertEqual(args.folder, command.in_file)
     self.assertIsNone(args.file)
     self.assertEqual("test.txt", command.out_file)
     self.assertEqual("python", command.language)
示例#3
0
 def test_input_folder_not_exist(self):
     with self.assertRaises(SystemExit) as cm:
         args = self.parser.parse_args(["-F", "not_exist"])
         command = evaluator.CommandLine(self.parser, args)
         self.assertIn("Folder supplied does not exist",
                       self.patcher1.getvalue().strip())
         the_exception = cm.exception
         self.assertEqual(the_exception.code, 1)
示例#4
0
 def test_invalid_file_name(self):
     with self.assertRaises(SystemExit) as cm:
         args = self.parser.parse_args(["-f", "no_file"])
         command = evaluator.CommandLine(self.parser, args)
         self.assertIn("File name not valid",
                       self.patcher1.getvalue().strip())
         the_exception = cm.exception
         self.assertEqual(the_exception.code, 1)
示例#5
0
 def test_no_args(self):
     with self.assertRaises(SystemExit) as cm:
         args = self.parser.parse_args([])
         command = evaluator.CommandLine(self.parser, args)
         self.assertIn("You need to supply input file or folder",
                       self.patcher1.getvalue().strip())
         the_exception = cm.exception
         self.assertEqual(the_exception.code, 1)
示例#6
0
 def test_language_not_supported(self):
     with self.assertRaises(SystemExit) as cm:
         args = self.parser.parse_args(["-F", "not_exist", "-l", "html"])
         command = evaluator.CommandLine(self.parser, args)
         self.assertIn("Language not supported",
                       self.patcher1.getvalue().strip())
         the_exception = cm.exception
         self.assertEqual(the_exception.code, 1)
示例#7
0
 def test_no_matching_files(self):
     with self.assertRaises(SystemExit) as cm:
         args = self.parser.parse_args(["-F", "tests"])
         command = evaluator.CommandLine(self.parser, args)
         self.assertIn("No matching files in folder supplied",
                       self.patcher1.getvalue().strip())
         the_exception = cm.exception
         self.assertEqual(the_exception.code, 1)
示例#8
0
 def test_language_match(self):
     with self.assertRaises(SystemExit) as cm:
         args = self.parser.parse_args(["-f", "no_file.py", "-l", "html"])
         command = evaluator.CommandLine(self.parser, args)
         self.assertEqual("Language does not match file", command.language)
         self.assertIn("Language does not match file",
                       self.patcher1.getvalue().strip())
         the_exception = cm.exception
         self.assertEqual(the_exception.code, 1)