{"id":23810,"library":"gradescope-utils","title":"gradescope-utils","description":"Utilities for building Gradescope autograders. Current version 0.5.0, released June 2022. The library provides decorators and a JSON test runner to streamline autograder development. Low release cadence.","status":"active","version":"0.5.0","language":"python","source_language":"en","source_url":"https://github.com/gradescope/gradescope-utils","tags":["gradescope","autograder","testing","education"],"install":[{"cmd":"pip install gradescope-utils","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"JSONTestRunner is exposed at the top-level package, not in a submodule.","wrong":"from gradescope_utils.runner import JSONTestRunner","symbol":"JSONTestRunner","correct":"from gradescope_utils import JSONTestRunner"},{"note":"Decorators must be imported from the decorators submodule.","wrong":"from gradescope_utils import weight","symbol":"weight","correct":"from gradescope_utils.decorators import weight"},{"note":"number is a separate decorator in the same module.","wrong":"from gradescope_utils.decorators.weight import number","symbol":"number","correct":"from gradescope_utils.decorators import number"},{"note":"","symbol":"partial_credit","correct":"from gradescope_utils.decorators import partial_credit"},{"note":"","symbol":"visibility","correct":"from gradescope_utils.decorators import visibility"},{"note":"Leaderboard decorator is available; leaderboard functionality must be enabled on Gradescope.","symbol":"leaderboard","correct":"from gradescope_utils.decorators import leaderboard"},{"note":"Utility function is in autograder_utils submodule.","wrong":"from gradescope_utils import check_submitted_files","symbol":"check_submitted_files","correct":"from gradescope_utils.autograder_utils import check_submitted_files"}],"quickstart":{"code":"import unittest\nfrom gradescope_utils import JSONTestRunner\nfrom gradescope_utils.decorators import weight\n\nclass TestHello(unittest.TestCase):\n    @weight(1)\n    def test_hello(self):\n        self.assertEqual('hello', 'hello')\n\nif __name__ == '__main__':\n    suite = unittest.defaultTestLoader.discover('tests')\n    JSONTestRunner(visibility='visible').run(suite)","lang":"python","description":"Basic autograder using unittest and gradescope-utils decorators."},"warnings":[{"fix":"Update to >=0.3.1 or pass number as a string.","message":"The @number decorator argument must be a string. In version 0.3.1 it was converted to string automatically, but in earlier versions you had to pass a string explicitly.","severity":"gotcha","affected_versions":"<0.3.1"},{"fix":"Set visibility on the runner and ensure individual tests don't override incorrectly.","message":"JSONTestRunner's visibility parameter only works if the test suite top-level visibility is not overridden by individual test visibilities. Use 'visible', 'after_published', or 'hidden'.","severity":"gotcha","affected_versions":">=0.2.7"},{"fix":"Inside the test method, set self.score to the desired score (float or int).","message":"The @partial_credit decorator requires you to set the score via the test case's 'score' attribute; it does not automatically compute partial credit.","severity":"gotcha","affected_versions":">=0.3.0"},{"fix":"For deeper checks, implement custom validation.","message":"The check_submitted_files utility checks for file existence only; it does not check file content or directory structure beyond the base path.","severity":"gotcha","affected_versions":">=0.2.4"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Upgrade to latest: pip install --upgrade gradescope-utils","cause":"Installed version is too old (pre 0.1).","error":"ImportError: cannot import name 'JSONTestRunner' from 'gradescope_utils'"},{"fix":"Run: pip install gradescope-utils","cause":"Package not installed or installed in a different environment.","error":"ModuleNotFoundError: No module named 'gradescope_utils'"},{"fix":"Use: from gradescope_utils.decorators import weight","cause":"Importing decorator directly from top-level package instead of submodule.","error":"AttributeError: module 'gradescope_utils' has no attribute 'weight'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}