From 749e3ad742c3563e43cd2b51cf85cdf0c4775093 Mon Sep 17 00:00:00 2001 From: iraida07 Date: Sun, 10 May 2020 03:44:04 -0500 Subject: [PATCH] =?UTF-8?q?:sparkles:=20Se=20desarrollan=20pruebas=20,=20s?= =?UTF-8?q?e=20completa=20clousure=20'make=5Fdivision=5Fby'=20y=20se=20da?= =?UTF-8?q?=20soluci=C3=B3n=20al=20reto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- challenge.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/challenge.py b/challenge.py index 2653d7e..3b6b187 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): + return int(x / n) + return division + def run(): @@ -21,8 +23,20 @@ def run(): import unittest class ClosureSuite(unittest.TestCase): + def setUp(self): + self.results = [6, 20, 3] + def test_closure_make_division_by(self): - # Make the closure test here - pass + divisors = [3, 5, 18] + dividents = [18, 100, 54] + + for result, divisor, divident in zip(self.results, divisors, dividents): + division_by_divisor = make_division_by(divisor) + self.assertEqual(result, division_by_divisor(divident)) + + def tearDown(self): + del(self.results) + + unittest.main() run()