From bd472f2e3c3f78d96926ccfa329029f3a8c6d695 Mon Sep 17 00:00:00 2001 From: Antonio Date: Sun, 21 Jun 2020 20:21:47 -0500 Subject: [PATCH] challenge solved --- challenge.py | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/challenge.py b/challenge.py index 2653d7e..820c344 100644 --- a/challenge.py +++ b/challenge.py @@ -2,8 +2,10 @@ def make_division_by(n): """This closure returns a function that returns the division of an x number by n """ - # You have to code here! - pass + def division(x): + assert x != 0, 'Denominator can\'t be zero' + return x / n + return division def run(): @@ -19,10 +21,27 @@ def run(): if __name__ == '__main__': import unittest - + run() class ClosureSuite(unittest.TestCase): - def test_closure_make_division_by(self): - # Make the closure test here - pass - run() + def setUp(self): + self.tests = { + 6: [18,3], + 20: [100,5], + 3: [54,18], + } + + + def test_closure_make_division_by(self): + for result, test in self.tests.items(): + division_n = make_division_by(test[1]) + self.assertEqual(result, division_n(test[0])) + del(division_n) + + + def tearDown(self): + del(self.tests) + + + unittest.main() +