'`FlockerScriptRunner._parse_options` catches `usage.UsageError`
exceptions and writes the help text and an error message to `stderr`
before exiting with status 1.'

def test_parse_options_usage_error(self):

    expectedMessage = 'foo    bar    baz'
    expectedCommandName = 'test_command'
    class FakeOptions(usage.Options, ):
        synopsis = ('Usage:    %s    [options]' % (expectedCommandName,))
        def parseOptions(self, arguments):
            raise usage.UsageError(expectedMessage)
    fake_sys = FakeSysModule()
    runner = FlockerScriptRunner(script=None, options=FakeOptions(), sys_module=fake_sys)
    error = self.assertRaises(SystemExit, runner._parse_options, [])
    expectedErrorMessage = ('ERROR:    %s\n' % (expectedMessage,))
    errorText = fake_sys.stderr.getvalue()
    self.assertEqual((1, [], expectedErrorMessage), (error.code, help_problems(u'test_command', errorText), errorText[(- len(expectedErrorMessage)):]))
