Skip to content

Commit

Permalink
Merge pull request #35 from AndrewQuijano/master
Browse files Browse the repository at this point in the history
Enable Gradescope and Django Integration
  • Loading branch information
ibrahima authored Mar 28, 2023
2 parents f1017f6 + cd26922 commit 0e642ef
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
15 changes: 15 additions & 0 deletions gradescope_utils/autograder_utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,18 @@ Example output:
]
}
```

### GradescopeDjangoRunner
This allows for an integration between Django testing, which utilizes unittest and
Gradescope's JSONTestRunner to obtain the JSON output of the Django test cases.
To enable this, complete the following steps:

First, in your settings.py, insert the line:
```
`TEST_RUNNER = 'gradescope_utils.autograder_utils.gradescope_django_runner.GradescopeDjangoRunner'`
```

Then, within your `run_autograder`, run the following command:
```
python3 manage.py test -v 0 > /autograder/results/results.json
```
13 changes: 13 additions & 0 deletions gradescope_utils/autograder_utils/gradescope_django_runner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import sys
from django.test.runner import DiscoverRunner
from gradescope_utils.autograder_utils.json_test_runner import JSONTestRunner


class GradescopeDjangoRunner(DiscoverRunner):
"""Replacing Django Default Unit Test Runner with Gradescope Test Runner"""

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def run_suite(self, suite, **kwargs):
return JSONTestRunner(**kwargs).run(suite)

0 comments on commit 0e642ef

Please sign in to comment.