Last active
July 6, 2020 17:43
-
-
Save acbart/32ecc194870eb98a452448b35c11378e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if -100 <= x <= 100: | |
| in_range = True | |
| else: | |
| in_range = False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sources import get_student_source, set_student_source | |
| remembered_code = get_student_source() | |
| class TestCase(EdfinityTestCase): | |
| # Problem: Assign a boolean based on whether the variable x is in a range | |
| def injectBefore(self, new_code): | |
| final_code = new_code + "\n" + remembered_code | |
| set_student_source(final_code) | |
| def test_out_of_bounds(self): | |
| self.injectBefore("x = -1000") | |
| self.assertEqual(self.student().in_range, False, "Tried x=-1000") | |
| def test_in_bounds(self): | |
| self.injectBefore("x = 50") | |
| self.assertEqual(self.student().in_range, True, "Tried x=50") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment