human
I am working on the file "Spring2019/04a_Exceptions_and_Testing/unit-tests.ipynb".
The first task is:
Testing For Exceptions
Edge test cases often involves handling exceptions. One approach is to code this directly.
Can you write Python code for it?
assistant
#Here is the Python code you requested.

import unittest

# Define a class in which the tests will run
class TestEntropy(unittest.TestCase):
        
    def test_invalid_probability(self):
        try:
            entropy([0.1, 0.5])
            self.assertTrue(False)
        except ValueError:
            self.assertTrue(True)
        
#test_setup(TestEntropy)