diff --git a/config.py b/config.py index cd8546f..8d44dd2 100644 --- a/config.py +++ b/config.py @@ -38,7 +38,8 @@ INFO_UNSUPPORTED_TEST = '[INFO] Unsupported Test' # snarky comment control -SNARKY_SUBMISSION_CNT_THRESHHOLD = 0.9 # be snarky when score < 90% +SNARKY_SUBMISSION_CNT_THRESHHOLD = 0.9 # be snarky only when score < 90% +# see also: snarky_submission_comments.py # cpp compilation config CXX = 'g++' diff --git a/documentation/files.md b/documentation/files.md index 422ba74..c37dee0 100644 --- a/documentation/files.md +++ b/documentation/files.md @@ -2,9 +2,11 @@ | file | description | | ---- | ----------- | +| `config.py` | Constants that are more-or-less configurable. | | `documentation/files.md` | descriptions of all files | | `documentation/README.md` | links to documentation | | `documentation/test_specifications.md` | documentation on the test specification format | +| `snarky_submission_comments.py` | configuration for snarky comments about the number of submissions | | `support/c++/test_compiling.py` | helper methods for compiling c++ tests
contains the method `compile_test(test: Attributes) -> Tuple[bool, str]` | | `support/c++/test_running.py` | helper methods for running c++ tests
contains the method `run_test(test: Attributes) -> PartialTestResult` | | `support/c++/test_writing.py` | helper methods for writing c++ tests
contains the method `write_test(test: Attributes) -> None` | diff --git a/run_tests.py b/run_tests.py index d01d5d9..672ebb5 100644 --- a/run_tests.py +++ b/run_tests.py @@ -2,9 +2,8 @@ ''' TODO(pcr): -* move configuration stuff to configuration file (and let it be assignment-specific) +* enable assignment-specific configuration stuff * refine attribute requirements -* add command line option to run a specific test or set of tests * use @target attribute for coverage tests and some other test(s) that don't use it but could/should ''' @@ -12,8 +11,13 @@ from os.path import exists as path_exists import json from argparse import ArgumentParser, Namespace -from config import DEFAULT_STDOUT_VISIBILITY, DEFAULT_VISIBILITY, OCTOTHORPE_LINE, OCTOTHORPE_WALL,\ - SNARKY_SUBMISSION_CNT_THRESHHOLD +from config import ( + DEFAULT_STDOUT_VISIBILITY, + DEFAULT_VISIBILITY, + OCTOTHORPE_LINE, + OCTOTHORPE_WALL, + SNARKY_SUBMISSION_CNT_THRESHHOLD) +from snarky_submission_comments import snarky_comment_about_number_of_submissions from results import Result, TestResult from test_parsing import read_tests from attributes import Attributes @@ -275,53 +279,6 @@ def main(args: Namespace) -> Result: } ) -def snarky_comment_about_number_of_submissions(num_submissions: int) -> str: - ''' - make a snarky comment based on their number of submissions - ''' - comment = "I'm not even mad, that's amazing." - if num_submissions < 4: - comment = ( - "That's OK. Make sure that you reflect on the feedback and think before you code. " - "Before making another submission, write test cases to reproduce the errors and then " - "use your favorite debugging technique to isolate and fix the errors. You can do it!") - elif num_submissions < 7: - comment = ( - "You should take some time before your next submission to think about the errors and " - "how to fix them. Start by reproducing the errors with test cases locally.") - elif num_submissions < 10: - comment = ( - "Why don't you take a break, take a walk, take nap, and come back to this " - "after you've had a chance to think a bit more. " - "Remember: start by reproducing the error, then isolate it and fix it.") - elif num_submissions < 15: - comment = ( - "It looks like you're having difficulty finding and fixing your errors. " - "You should come to office hours. We can help you.") - elif num_submissions < 20: - comment = ( - "If you haven't gone to office hours yet, you really should. " - "We want to help you. How's your coverage? You can't test what you don't cover.") - elif num_submissions < 30: - comment = ( - "Did you know that you can not only compile locally, but you can also test locally? " - "You should try it.") - elif num_submissions < 40: - comment = ( - "literally nobody: \n" - " you: autograder go brrr.") - elif num_submissions < 50: - comment = ( - "I'm almost out of snarky ways to comment on how many submissions you've made. " - "That's how many submissions you've made.") - elif num_submissions < 75: - comment = ( - "Big yikes. No cap, fam, take several seats. This ain't it, chief. " - "Your code and development process are sus AF. Periodt.") - elif num_submissions < 100: - comment = "Your number of submissions to this assignment is too damn high." - return comment + '\n' - def ordinal_suffix(number: int) -> str: ''' determine the ordinal suffix for the given integer, e.g. 1st, 2nd, 3rd, 4th, etc. diff --git a/snarky_submission_comments.py b/snarky_submission_comments.py new file mode 100644 index 0000000..f6da4f2 --- /dev/null +++ b/snarky_submission_comments.py @@ -0,0 +1,80 @@ +''' +configuration for snarky comments about the number of submissions +''' + +# the comment to make when the number of submissions exceeds all threshholds +ULTIMATE_COMMENT = "I'm not even mad, that's amazing." + +# try to keep this in increasing order of threshhold +# but if you mess it up, there is a sort at the end which will fix it for you +SNARKY_SUBMISSION_COMMENTS = [ + # upper submission threshhold, comment + ( + 4, + ("That's OK. Make sure that you reflect on the feedback and think before you code. " + "Before making another submission, write test cases to reproduce the errors and then " + "use your favorite debugging technique to isolate and fix the errors. You can do it!") + ), + ( + 7, + ("You should take some time before your next submission to think about the errors and " + "how to fix them. Start by reproducing the errors with test cases locally.") + ), + ( + 10, + ("Why don't you take a break, take a walk, take nap, and come back to this " + "after you've had a chance to think a bit more. " + "Remember: start by reproducing the error, then isolate it and fix it.") + ), + ( + 15, + ("It looks like you're having difficulty finding and fixing your errors. " + "You should come to office hours. We can help you.") + ), + ( + 20, + ("If you haven't gone to office hours yet, you really should. " + "We want to help you. How's your coverage? You can't test what you don't cover.") + ), + ( + 30, + ("Did you know that you can not only compile locally, but you can also test locally? " + "You should try it.") + ), + ( + 40, + ("literally nobody: \n" + " you: autograder go brrr.") + ), + ( + 50, + ("I'm almost out of snarky ways to comment on how many submissions you've made. " + "That's how many submissions you've made.") + ), + ( + 75, + ("Big yikes. No cap, fam, take several seats. This ain't it, chief. " + "Your code and development process are sus AF. Periodt.") + ), + ( + 100, + "Your number of submissions to this assignment is too damn high." + ) + ] + +# sort the entries by ascending threshhold (just in case) +SNARKY_SUBMISSION_COMMENTS.sort(key=lambda t : t[0]) + +def snarky_comment_about_number_of_submissions(num_submissions: int) -> str: + """make a snarky comment based on their number of submissions + + Args: + num_submissions (int): the number of submissions (i.e. the number of this submission) + + Returns: + str: a (snarky) comment about the number of submissions + """ + for submission_threshhold, comment in SNARKY_SUBMISSION_COMMENTS: + if num_submissions < submission_threshhold: + return comment + '\n' + return ULTIMATE_COMMENT + '\n' diff --git a/tests/test_snarky_submission_comments.py b/tests/test_snarky_submission_comments.py new file mode 100644 index 0000000..8e424ef --- /dev/null +++ b/tests/test_snarky_submission_comments.py @@ -0,0 +1,27 @@ +""" +tests for snarky_comment_about_number_of_submissions +""" +import unittest + +from snarky_submission_comments import snarky_comment_about_number_of_submissions + +class TestSnarkyComments(unittest.TestCase): + """ + tests for snarky_comment_about_number_of_submissions + """ + def test_snarky_comments(self): + """ + tests for snarky_comment_about_number_of_submissions + """ + self.assertTrue(snarky_comment_about_number_of_submissions(1).startswith('That\'s OK.')) + self.assertTrue(snarky_comment_about_number_of_submissions(3).startswith('That\'s OK.')) + self.assertTrue( + snarky_comment_about_number_of_submissions(4).startswith('You should take some time')) + self.assertEqual( + snarky_comment_about_number_of_submissions(99), + 'Your number of submissions to this assignment is too damn high.\n' + ) + self.assertEqual( + snarky_comment_about_number_of_submissions(100), + 'I\'m not even mad, that\'s amazing.\n' + )