PKDaHgradescope_utils/__init__.pyPKWCaH-gradescope_utils/autograder_utils/__init__.pyPKWCaH[Äàm/gradescope_utils/autograder_utils/decorators.pyclass weight(object): """Simple decorator to add a __weight__ property to a function Usage: @weight(3.0) """ def __init__(self, val): self.val = val def __call__(self, func): func.__weight__ = self.val return func class tags(object): """Simple decorator to add a __tags__ property to a function Usage: @tags("concept1", "concept2") """ def __init__(self, *args): self.tags = args def __call__(self, func): func.__tags__ = self.tags return func PK'*eHPÝ?CÉÉ5gradescope_utils/autograder_utils/json_test_runner.py"""Running tests""" from __future__ import print_function import sys import time import json from unittest import result from unittest.signals import registerResult class JSONTestResult(result.TestResult): """A test result class that can print formatted text results to a stream. Used by JSONTestRunner. """ def __init__(self, stream, descriptions, verbosity, results): super(JSONTestResult, self).__init__(stream, descriptions, verbosity) self.descriptions = descriptions self.results = results def getDescription(self, test): doc_first_line = test.shortDescription() if self.descriptions and doc_first_line: return doc_first_line else: return str(test) def getTags(self, test): return getattr(getattr(test, test._testMethodName), '__tags__', None) def getWeight(self, test): return getattr(getattr(test, test._testMethodName), '__weight__', 0.0) def startTest(self, test): super(JSONTestResult, self).startTest(test) def getOutput(self): if self.buffer: out = self._stdout_buffer.getvalue() err = self._stderr_buffer.getvalue() if err: if not out.endswith('\n'): out += '\n' out += err return out def buildResult(self, test, passed): weight = self.getWeight(test) tags = self.getTags(test) output = self.getOutput() result = { "name": self.getDescription(test), "score": weight if passed else 0.0, "max_score": weight, } if tags: result["tags"] = tags if output and len(output) > 0: result["output"] = output return result def addSuccess(self, test): super(JSONTestResult, self).addSuccess(test) self.results.append(self.buildResult(test, True)) def addError(self, test, err): super(JSONTestResult, self).addError(test, err) print("ERROR:", err[1]) self.results.append(self.buildResult(test, False)) def addFailure(self, test, err): super(JSONTestResult, self).addFailure(test, err) print("Test Failed:", str(err[1])) self.results.append(self.buildResult(test, False)) class JSONTestRunner(object): """A test runner class that displays results in JSON form. """ resultclass = JSONTestResult def __init__(self, stream=sys.stderr, descriptions=True, verbosity=1, failfast=False, buffer=False): """ Set buffer to True to include test output in JSON """ self.stream = stream self.descriptions = descriptions self.verbosity = verbosity self.failfast = failfast self.buffer = buffer self.json_data = {} self.json_data["tests"] = [] def _makeResult(self): return self.resultclass(self.stream, self.descriptions, self.verbosity, self.json_data["tests"]) def run(self, test): "Run the given test case or test suite." result = self._makeResult() registerResult(result) result.failfast = self.failfast result.buffer = self.buffer startTime = time.time() startTestRun = getattr(result, 'startTestRun', None) if startTestRun is not None: startTestRun() try: test(result) finally: stopTestRun = getattr(result, 'stopTestRun', None) if stopTestRun is not None: stopTestRun() stopTime = time.time() timeTaken = stopTime - startTime self.json_data["execution_time"] = format(timeTaken, "0.2f") total_score = 0 for test in self.json_data["tests"]: total_score += test["score"] self.json_data["score"] = total_score json.dump(self.json_data, self.stream, indent=4) self.stream.write('\n') return result PK|+eHǽlÄ^^0gradescope_utils-0.1.2.dist-info/DESCRIPTION.rst# Gradescope Python Utilities - [Autograder Utilities](/gradescope_utils/autograder_utils) PK|+eHÛÄŽEE.gradescope_utils-0.1.2.dist-info/metadata.json{"classifiers": ["Development Status :: 3 - Alpha", "Intended Audience :: Developers", "Topic :: Software Development :: Build Tools", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5"], "extensions": {"python.details": {"contacts": [{"email": "ibrahim@gradescope.com", "name": "Ibrahim Awwal", "role": "author"}], "document_names": {"description": "DESCRIPTION.rst"}, "project_urls": {"Home": "https://github.com/gradescope/gradescope-utils"}}}, "extras": ["dev", "test"], "generator": "bdist_wheel (0.26.0)", "keywords": ["gradescope", "http", "service"], "license": "MIT", "metadata_version": "2.0", "name": "gradescope-utils", "run_requires": [{"extra": "dev", "requires": ["check-manifest"]}, {"extra": "test", "requires": ["coverage"]}], "summary": "Utilities for interacting with Gradescope", "version": "0.1.2"}PK|+eHù ” .gradescope_utils-0.1.2.dist-info/top_level.txtgradescope_utils PK|+eHìndªnn&gradescope_utils-0.1.2.dist-info/WHEELWheel-Version: 1.0 Generator: bdist_wheel (0.26.0) Root-Is-Purelib: true Tag: py2-none-any Tag: py3-none-any PK|+eH<€+"")gradescope_utils-0.1.2.dist-info/METADATAMetadata-Version: 2.0 Name: gradescope-utils Version: 0.1.2 Summary: Utilities for interacting with Gradescope Home-page: https://github.com/gradescope/gradescope-utils Author: Ibrahim Awwal Author-email: ibrahim@gradescope.com License: MIT Keywords: gradescope http service Platform: UNKNOWN Classifier: Development Status :: 3 - Alpha Classifier: Intended Audience :: Developers Classifier: Topic :: Software Development :: Build Tools Classifier: License :: OSI Approved :: MIT License Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Provides-Extra: dev Requires-Dist: check-manifest; extra == 'dev' Provides-Extra: test Requires-Dist: coverage; extra == 'test' # Gradescope Python Utilities - [Autograder Utilities](/gradescope_utils/autograder_utils) PK|+eHþ8_‘±±'gradescope_utils-0.1.2.dist-info/RECORDgradescope_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 gradescope_utils/autograder_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 gradescope_utils/autograder_utils/decorators.py,sha256=7Tf0-3NKnZkRfs3js_Qpb18e93G2c76c6aaeDP-PSWs,538 gradescope_utils/autograder_utils/json_test_runner.py,sha256=KLol1nHYJw4lxPVohb3yDMlTmPMBU4iqBfg5gWhbGys,4041 gradescope_utils-0.1.2.dist-info/DESCRIPTION.rst,sha256=KmRlVd9JI5Gx8E3dKfOeB7I-1Ebi9E0LXPfaN_X0dNE,94 gradescope_utils-0.1.2.dist-info/METADATA,sha256=_Gxt7SA4L1EEOt3DV0T6j-ICP_eC5pSnjmCeE1amCF4,1058 gradescope_utils-0.1.2.dist-info/RECORD,, gradescope_utils-0.1.2.dist-info/WHEEL,sha256=GrqQvamwgBV4nLoJe0vhYRSWzWsx7xjlt74FT0SWYfE,110 gradescope_utils-0.1.2.dist-info/metadata.json,sha256=qqSK-jza-pnbb4hRO2PovVUS4rT5shDwM64tTkZcJV0,1093 gradescope_utils-0.1.2.dist-info/top_level.txt,sha256=OWJXD0Ey6lDjiRWeQashG_lmieSeOkcIwcY7pfVvS4w,17 PKDaHgradescope_utils/__init__.pyPKWCaH-:gradescope_utils/autograder_utils/__init__.pyPKWCaH[Äàm/…gradescope_utils/autograder_utils/decorators.pyPK'*eHPÝ?CÉÉ5ìgradescope_utils/autograder_utils/json_test_runner.pyPK|+eHǽlÄ^^0gradescope_utils-0.1.2.dist-info/DESCRIPTION.rstPK|+eHÛÄŽEE.´gradescope_utils-0.1.2.dist-info/metadata.jsonPK|+eHù ” .Egradescope_utils-0.1.2.dist-info/top_level.txtPK|+eHìndªnn&¢gradescope_utils-0.1.2.dist-info/WHEELPK|+eH<€+"")Tgradescope_utils-0.1.2.dist-info/METADATAPK|+eHþ8_‘±±'½gradescope_utils-0.1.2.dist-info/RECORDPK {³!