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)
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)
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)
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)
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)
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)
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)
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)