Package: aga
aga grades assignmentsaga(agagradesassignments) is a tool for easily producing autograders for python programming assignments, originally developed for Reed College's CS1 course.MotivationUnlike traditional software testing, where there is likely noa prioriknown-correct implementation, there is always such an implementation (or one can be easily written by course staff) in homework grading. Therefore, applying traditional software testing frameworks to homework grading is limited. Relying on reference implementations (what aga callsgolden solutions) has several benefits:Reliability: having a reference solution gives a second layer of confirmation for the correctness of expected outputs. Aga supportsgolden tests, which function as traditional unit tests of the golden solution.Test case generation: many complex test cases can easily be generated via the reference solution, instead of needing to work out the expected output by hand. Aga supports generating test cases from inputs without explcitly referring to an expected output, and supports collecting test cases from python generators.Property testing: unit testing libraries likehypothesisallow testing large sets of arbitrary inputs for certain properties, and identifying simple inputs which reproduce violations of those properties. This is traditionally unreliable, because identifying specific properties to test is difficult. In homework grading, the property can simply be "the input matches the golden solution's output." Support for hypothesis is along-term goalof aga.InstallationInstall from pip:pipinstallagaor with the python dependency manager of your choice (I likepoetry), for example:curl-sSLhttps://install.python-poetry.org|python3-echo"cd into aga repo"cdaga
poetryinstall&&poetryshellExampleInsquare.py(or any python file), write:fromagaimportproblem,test_case,test_cases@test_cases(-3,100)@test_case(2,aga_expect=4)@test_case(-2,aga_expect=4)@problem()defsquare(x:int)->int:"""Square x."""returnx*xThen runaga gen square.pyfrom the directory withsquare.py. This will generate a ZIP file suitable for upload to Gradescope.UsageAga relies on the notion of agolden solutionto a given problem which is known to be correct. The main work of the library is to compare the output of this golden solution on some family of test inputs against the output of a student submission. To that end, aga integrates with frontends: existing classroom software which allow submission of student code. Currently, only Gradescope is supported.To use aga:Write a golden solution to some programming problem.Decorate this solution with theproblemdecorator.Decorate this problem with any number oftest_casedecorators, which take arbitrary positional or keyword arguments and pass them verbatim to the golden and submitted functions.Generate the autograder using the CLI:aga gen <file_name>.Thetest_casedecorator may optionally take a special keyword argument calledaga_expect. This allows easy testing of the golden solution: aga will not successfully produce an autograder unless the golden solution's output matches theaga_expect. You should use these as sanity checks to ensure your golden solution is implemented correctly.For more info, see thetutorial.For complete documentation, including configuring problem and test case metadata, see theAPI reference.For CLI documentation, runaga --help, or access the docsonline.ContributingBug reports, feature requests, and pull requests are all welcome. For details on our test suite, development environment, and more, see thedeveloper documentation.