コード例 #1
0
    def test_parseInsufficientArgs_fails(self):
        test_namespace = Namespace()
        setattr(test_namespace, 'sourceRepo', '/dev/null/source/Trilinos.git')
        expected_output = '''usage: programName [-h]
                   sourceRepo sourceBranch targetRepo targetBranch sourceSHA
                   workspaceDir
programName: error: the following arguments are required: sourceRepo, \
sourceBranch, targetRepo, targetBranch, sourceSHA, workspaceDir
'''
        if sys.version_info.major is not 3:
            expected_output = '''usage: programName [-h]
                   sourceRepo sourceBranch targetRepo targetBranch sourceSHA
                   workspaceDir\nprogramName: error: too few arguments
'''
        with mock.patch.object(sys, 'argv', ['programName']), \
                mock.patch('sys.stderr', new_callable=StringIO) as m_stderr:
            if sys.version_info.major is not 3:
                with self.assertRaisesRegexp(SystemExit, '2'):
                    PullRequestLinuxDriverMerge.parseArgs()
            else:
                with self.assertRaisesRegex(SystemExit, '2'):
                    PullRequestLinuxDriverMerge.parseArgs()
        self.assertEqual(expected_output, m_stderr.getvalue())
コード例 #2
0
    def test_parseArgs(self):
        test_namespace = Namespace()
        setattr(test_namespace, 'sourceRepo', '/dev/null/source/Trilinos.git')
        setattr(test_namespace, 'sourceBranch',
                'fake_test_branch_fixing_issue_neverland')
        setattr(test_namespace, 'targetRepo', '/dev/null/target/Trilinos.git')
        setattr(test_namespace, 'targetBranch', 'fake_develop')
        setattr(test_namespace, 'sourceSHA', '0123456789abcdef')
        setattr(test_namespace, 'workspaceDir', '/dev/null/workspace')

        with mock.patch.object(sys, 'argv', [
                'programName',
                os.path.join(os.path.sep, 'dev', 'null', 'source',
                             'Trilinos.git'),
                'fake_test_branch_fixing_issue_neverland',
                os.path.join(os.path.sep, 'dev', 'null', 'target',
                             'Trilinos.git'), 'fake_develop',
                '0123456789abcdef',
                os.path.join(os.path.sep, 'dev', 'null', 'workspace')
        ]):

            args = PullRequestLinuxDriverMerge.parseArgs()
        self.assertEqual(test_namespace, args)