def test_xy_adder_active(self): """ _xy_adder() adds proper arguments """ # set up mock parser parser = MagicMock() parser.add_argument = MagicMock() # create a list of expected call signatures calls = [] msg = 'Column to plot on x-axis' calls.append(call('-x', nargs=1, type=str, dest='x', metavar='col', help=msg)) msg = 'List of columns to plot on y-axis' calls.append(call('-y', nargs='+', type=str, dest='y', metavar='col', help=msg)) msg = "Plot style(s) defaults to .-" calls.append(call('-s', '--style', nargs='+', type=str, dest='style', default=['.-'], help=msg, metavar='style')) # run the code under test args = ['xy_plotting'] arg_lib._xy_adder(parser, *args) # make sure proper calls were made self.assertEqual(parser.add_argument.call_args_list, calls)
def test_xy_adder_inactive(self): """ _xy_adder() doesn't do anything when xy_plotting not specified """ parser = MagicMock() parser.add_argument = MagicMock() args = [] arg_lib._xy_adder(parser, *args) self.assertFalse(parser.add_argument.called)