# testgym.py # Walker M. White (wmw2), Lillian Lee (LJL2) # Jan 31, 2013 """Unit test for the module gym. This module illustrates what a unit test should look like. It is testing a single function in the module gym, and therefore has a single test procedure. It also has a segment of "application code" that invokes the test procedure when this module is run as an application.""" import cunittest # cunittest assert functions import gym # file containing function to test def test_dscore(): """Test procedure for gym.dscore_alt()""" cunittest.assert_floats_equal(6.7, gym.dscore('RAISMAN, 6.7, 9.0, 0')) cunittest.assert_floats_equal(6.2, gym.dscore('PONOR , 6.2 , 9.0 , 0')) cunittest.assert_floats_equal(7.0, gym.dscore(' SMITH , 7, 9 , 0')) cunittest.assert_floats_equal(5.2, gym.dscore(' SMITH-JONES , 5.2 , 9 , 0')) def test_dscore_alt(): """Test procedure for gym.dscore_alt()""" cunittest.assert_floats_equal(6.7, gym.dscore_alt('RAISMAN, 6.7, 9.0, 0')) cunittest.assert_floats_equal(6.2, gym.dscore_alt('PONOR , 6.2 , 9.0 , 0')) cunittest.assert_floats_equal(7.0, gym.dscore_alt(' SMITH , 7, 9 , 0')) cunittest.assert_floats_equal(5.2, gym.dscore_alt(' SMITH-JONES , 5.2 , 9 , 0')) # Application code if __name__ == '__main__': test_dscore_alt() test_dscore() print 'Module gym is working correctly'