'Assert the options are what we expected when parsing arguments.
Otherwise, fail with a nicely formatted message.
Keyword arguments:
args -- A list of arguments to parse with OptionParser.
expected_opts -- The options expected.
expected_positional_args -- The positional arguments expected.
Returns the options and positional args for further testing.'

def assertParseOK(self, args, expected_opts, expected_positional_args):

    (options, positional_args) = self.parser.parse_args(args)
    optdict = vars(options)
    self.assertEqual(optdict, expected_opts, ('\nOptions    are    %(optdict)s.\nShould    be    %(expected_opts)s.\nArgs    were    %(args)s.' % locals()))
    self.assertEqual(positional_args, expected_positional_args, ('\nPositional    arguments    are    %(positional_args)s.\nShould    be    %(expected_positional_args)s.\nArgs    were    %(args)s.' % locals()))
    return (options, positional_args)
