def test_get_distribution_markers_insufficient_markers(self): """_get_distribution_markers() should return a wrapped list of predefined markers.""" # Save stdout and replace it with something that will capture the print # statement. Note: this code was taken from here: # http://stackoverflow.com/questions/4219717/how-to-assert-output- # with-nosetest-unittest-in-python/4220278#4220278 saved_stdout = sys.stdout try: out = StringIO() sys.stdout = out self.assertEqual(_get_distribution_markers('colors', None, 10), ['b', 'g', 'r', 'c', 'm', 'y', 'w', 'b', 'g', 'r']) self.assertEqual(_get_distribution_markers('symbols', ['^', '>', '<'], 5), ['^', '>', '<', '^', '>']) output = out.getvalue().strip() self.assertEqual(output, "There are not enough markers to " "uniquely represent each distribution in your dataset. " "You may want to provide a list of markers that is at " "least as large as the number of distributions in your " "dataset.\nThere are not enough markers to " "uniquely represent each distribution in your dataset. " "You may want to provide a list of markers that is at " "least as large as the number of distributions in your " "dataset.") finally: sys.stdout = saved_stdout
def test_get_distribution_markers_insufficient_markers(self): """_get_distribution_markers() should return a wrapped list of predefined markers.""" # Save stdout and replace it with something that will capture the print # statement. Note: this code was taken from here: # http://stackoverflow.com/questions/4219717/how-to-assert-output- # with-nosetest-unittest-in-python/4220278#4220278 saved_stdout = sys.stdout try: out = StringIO() sys.stdout = out self.assertEqual( _get_distribution_markers('colors', None, 10), ['b', 'g', 'r', 'c', 'm', 'y', 'w', 'b', 'g', 'r']) self.assertEqual( _get_distribution_markers('symbols', ['^', '>', '<'], 5), ['^', '>', '<', '^', '>']) output = out.getvalue().strip() self.assertEqual( output, "There are not enough markers to " "uniquely represent each distribution in your dataset. " "You may want to provide a list of markers that is at " "least as large as the number of distributions in your " "dataset.\nThere are not enough markers to " "uniquely represent each distribution in your dataset. " "You may want to provide a list of markers that is at " "least as large as the number of distributions in your " "dataset.") finally: sys.stdout = saved_stdout
def test_get_distribution_markers_zero_markers(self): """_get_distribution_markers() should return an empty list.""" self.assertEqual(_get_distribution_markers('symbols', None, 0), []) self.assertEqual(_get_distribution_markers('symbols', ['^'], 0), [])
def test_get_distribution_markers_empty_marker_list(self): """_get_distribution_markers() should return a list of predefined matplotlib markers.""" self.assertEqual(_get_distribution_markers('colors', None, 4), ['b', 'g', 'r', 'c'])