Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions challenge.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
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 repeater(val):
return val / n
return repeater


def run():
Expand All @@ -21,8 +19,27 @@ def run():
import unittest

class ClosureSuite(unittest.TestCase):
def test_closure_make_division_by(self):
# Make the closure test here
pass

def setUp(self):
self.value_18 = 18
self.value_100 = 100
self.value_54 = 54

def test_closure_make_division_by_3(self):
division_by_3 = make_division_by(3)
self.assertEqual(6, division_by_3(self.value_18))

def test_closure_make_division_by_5(self):
division_by_5 = make_division_by(5)
self.assertEqual(20, division_by_5(self.value_100))

def test_closure_make_division_by_18(self):
division_by_18 = make_division_by(18)
self.assertEqual(3, division_by_18(self.value_54))

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incluye los test para 5, 18, como aparece en run()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Se incluyen 2 test adicionales

def tearDown(self):
del(self.value_18)
del(self.value_100)
del(self.value_54)

run()
unittest.main()