Beispiel #1
0
    def test_no_args(self):
        self.errmsg = None
        def fail(msg):
            self.errmsg = msg
            sys.exit(msg)

        with self.assertRaises(SystemExit):
            parse_args('cg', [], _fail=fail)

        self.assertEqual(self.errmsg, 'missing command')
Beispiel #2
0
    def test_check_no_args(self):
        cmd, cmdkwargs = parse_args('cg', [
            'check',
            ])

        self.assertEqual(cmd, 'check')
        self.assertEqual(cmdkwargs, {
            'ignored': IGNORED_FILE,
            'known': KNOWN_FILE,
            #'dirs': SOURCE_DIRS,
            })
Beispiel #3
0
    def test_show_no_args(self):
        cmd, cmdkwargs = parse_args('cg', [
            'show',
            ])

        self.assertEqual(cmd, 'show')
        self.assertEqual(cmdkwargs, {
            'ignored': IGNORED_FILE,
            'known': KNOWN_FILE,
            #'dirs': SOURCE_DIRS,
            'skip_objects': False,
            })
Beispiel #4
0
    def test_check_full_args(self):
        cmd, cmdkwargs = parse_args('cg', [
            'check',
            '--ignored', 'spam.tsv',
            '--known', 'eggs.tsv',
            #'dir1',
            #'dir2',
            #'dir3',
            ])

        self.assertEqual(cmd, 'check')
        self.assertEqual(cmdkwargs, {
            'ignored': 'spam.tsv',
            'known': 'eggs.tsv',
            #'dirs': ['dir1', 'dir2', 'dir3']
            })
Beispiel #5
0
    def test_show_full_args(self):
        cmd, cmdkwargs = parse_args('cg', [
            'show',
            '--ignored', 'spam.tsv',
            '--known', 'eggs.tsv',
            #'dir1',
            #'dir2',
            #'dir3',
            ])

        self.assertEqual(cmd, 'show')
        self.assertEqual(cmdkwargs, {
            'ignored': 'spam.tsv',
            'known': 'eggs.tsv',
            #'dirs': ['dir1', 'dir2', 'dir3'],
            'skip_objects': False,
            })
Beispiel #6
0
from cpython.__main__ import parse_args, main, configure_logger

cmd, cmd_kwargs, verbosity, traceback_cm = parse_args()
configure_logger(verbosity)
with traceback_cm:
    main(cmd, cmd_kwargs)
Beispiel #7
0
# This is a script equivalent of running "python -m test.test_c_globals.cg".

from cpython.__main__ import parse_args, main


# This is effectively copied from cg/__main__.py:
if __name__ == '__main__':
    cmd, cmdkwargs = parse_args()
    main(cmd, cmdkwargs)