Skip to content

How to use "unittest" grader

Outvi V edited this page Mar 6, 2019 · 2 revisions

We added a new grader called unittest.

To use this, add in your init.yml:

unit_test: unit.py  # Your unittest file
test_cases:
- {points: 50}  # Up to you
- {points: 50}  # Up to you

And also patch your python modules at /usr/lib/python3.x/unittest/main.py:

--- a/main.py    2018-12-07 18:00:00.000000000 +0000
+++ b/main.py     2018-12-07 18:01:00.000000000 +0000
@@ -230,7 +230,7 @@
             # it is assumed to be a TestRunner instance
             testRunner = self.testRunner
         self.result = testRunner.run(self.test)
-        if self.exit:
+        if not self.result.wasSuccessful():
             sys.exit(not self.result.wasSuccessful())

 main = TestProgram

(It's at the very end of this file. Line numbers may vary in different version.)

Clone this wiki locally