Skip to content

Instantly share code, notes, and snippets.

@acbart
Last active July 6, 2020 17:43
Show Gist options
  • Select an option

  • Save acbart/32ecc194870eb98a452448b35c11378e to your computer and use it in GitHub Desktop.

Select an option

Save acbart/32ecc194870eb98a452448b35c11378e to your computer and use it in GitHub Desktop.
if -100 <= x <= 100:
in_range = True
else:
in_range = False
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