>
>
>> Uh oh...  I'm in the middle of teaching Session 10
>> and couldn't figure out why my radius for a smaller
>> area was bigger.  Couldn't be.  I did my algebra
>> wrong, duh.
>>
>
>
> https://docs.python.org/2/library/unittest.html
>
> if __name__ == "__main__":
>     # import unittest
>     unittest.main()
>
>
>


Yeah, seriously good advice.

I've added unittests to the latest version, which I'll push to Github when
the site once again becomes available.

http://gizmodo.com/this-is-probably-why-half-the-internet-shut-down-today-1788062835


Kirby


class TestCircle(unittest.TestCase):

    def testArea(self):
        the_circle = Circle(1)
        self.assertEqual(the_circle.area, math.pi, "Uh oh")

    def testRadius(self):
        the_circle = Circle(1)
        the_circle.area = math.pi * 4 # power rule
        self.assertEqual(the_circle.radius, 2, "Uh oh")

a = TestCircle()  # the test suite
suite = unittest.TestLoader().loadTestsFromModule(a)
unittest.TextTestRunner().run(suite)  # run the test suite
_______________________________________________
Edu-sig mailing list
Edu-sig@python.org
https://mail.python.org/mailman/listinfo/edu-sig

Reply via email to