def test_Correct_Code(self): self.assertEqual(code_grader.compile_file(mydir + "compile_1.cpp", mydir + "compile_1"), ["Program compiled correctly."]) self.assertEqual(code_grader.compile_file(mydir + "compile_2.cpp", mydir + "compile_2") , ["Program compiled correctly."]) assert os.path.exists(mydir + "compile_1") == 1 assert os.path.exists(mydir + "compile_1") == 1 try: os.remove(mydir + "compile_1") os.remove(mydir + "compile_2") except: assert "ERROR"
def test_Warning_Code(self): self.assertEqual(code_grader.compile_file(mydir + "warning_1.cpp", mydir + "warning_1"), ["Program compiled, but generated warnings."]) self.assertEqual(code_grader.compile_file(mydir + "warning_2.cpp", mydir + "warning_2") , ["Program compiled, but generated warnings."]) assert os.path.exists(mydir + "warning_1") == 1 assert os.path.exists(mydir + "warning_2") == 1 try: os.remove(mydir + "warning_1") os.remove(mydir + "warning_2") except: assert "ERROR"
def test_Bad_Code(self): self.assertNotEqual(code_grader.compile_file(mydir + "no_compile.cpp", mydir + "no_compile"), ["Program compiled correctly."]) self.assertNotEqual(code_grader.compile_file(mydir + "no_compile_2.cpp", mydir + "no_compile_2"), ["Program compiled correctly."]) self.assertNotEqual(code_grader.compile_file(mydir + "no_compile.cpp", mydir + "no_compile"), ["Program compiled, but generated warnings."]) self.assertNotEqual(code_grader.compile_file(mydir + "no_compile_2.cpp", mydir + "no_compile_2"), ["Program compiled, but generated warnings."]) self.assertNotEqual(code_grader.compile_file(mydir + "no_compile.cpp", mydir + "no_compile"), ["Could not compile."]) self.assertNotEqual(code_grader.compile_file(mydir + "no_compile_2.cpp", mydir + "no_compile_2"), ["Could not compile."]) assert os.path.exists(mydir + "no_compile") != 1 assert os.path.exists(mydir + "no_compile") != 1