@@ -121,5 +121,74 @@ def test_run(self):
121121 "Accepted" , "Something Wrong" )
122122
123123
124+ # test to check ValueError exception
125+
126+
127+ class TestRunI (unittest .TestCase ):
128+
129+ def test_run (self ):
130+ with self .assertRaises (ValueError ): coderunner .code (
131+ "Hello World" ,
132+ "PHP" ,
133+ "Hello World" ,
134+ path = False
135+ )
136+
137+
138+ # test to check OSError exception
139+
140+
141+ class TestRunJ (unittest .TestCase ):
142+
143+ def test_run (self ):
144+ with self .assertRaises (OSError ): coderunner .code (
145+ "Hello World" ,
146+ "C++" ,
147+ "Hello World"
148+ )
149+
150+
151+ # test to check OSError exception
152+
153+
154+ class TestRunK (unittest .TestCase ):
155+
156+ def test_run (self ):
157+ with self .assertRaises (OSError ): coderunner .code (
158+ "testfiles/" + "test_c++.cpp" ,
159+ "C++" ,
160+ "Hello World"
161+ )
162+
163+
164+ # test to check OSError exception
165+
166+
167+ class TestRunL (unittest .TestCase ):
168+
169+ def test_run (self ):
170+ with self .assertRaises (OSError ): coderunner .code (
171+ "testfiles/" + "test_c++.cpp" ,
172+ "C++" ,
173+ "testfiles/output/" + "output4.txt" ,
174+ "my_input"
175+ )
176+
177+
178+ # test to check Wrong Answer Status
179+
180+
181+ class TestRunM (unittest .TestCase ):
182+
183+ def test_run (self ):
184+ source_code = "print(\" This will return Wrong Answer\" )"
185+ language = "Python"
186+ output = "Wrong Answer"
187+ r = coderunner .code (source_code , language , output , path = False )
188+ r .run ()
189+ self .assertEqual (r .getStatus (),
190+ "Wrong Answer" , "Something Wrong" )
191+
192+
124193if __name__ == '__main__' :
125194 unittest .main ()
0 commit comments