Пример #1
0
def process_arguments(argv: List[str], assignments: Set[Assignment], baseline: Assignment):
    try:
        if len(argv) <= 1:
            print_usage(option_flags, assignments)
            exit()

        set_home_path(Path(os.path.abspath(os.path.dirname(argv[0]))))

        args = parse_options(argv[1:], option_flags)

        assignment = parse_assignment(args, assignments)

        validate_options_for(assignment)

        if print_usage_flag:
            print_usage(option_flags, assignments)
            exit()

        if bulk_grade_mode:
            do_bulk_grading(assignment, baseline)
        else:
            check_assignment(assignment, baseline)

    finally:
        reset_state()
Пример #2
0
def process_arguments(argv: List[str], assignments: List[Assignment], baseline: List[Assignment]):
    all_assignments = baseline + assignments

    def curried_parse_assignment(assignment: str) -> Optional[Assignment]:
        return parse_assignment(assignment, all_assignments)

    parser = ArgumentParser(argv[0], formatter_class=RawDescriptionHelpFormatter,
            description=GRADER_SYNOPSIS, epilog=list_assignments_str(all_assignments))

    parser.add_argument('-q', action='store_true', default=False,
            help='print grade only', dest='quiet')
    parser.add_argument('-b', default=None, metavar="<file>",
            help='bulk grade assignments given as github commit links in file',
            dest='bulk_file')
    parser.add_argument('-d', default=None, metavar="<directory>",
            help='directory where all bulk-graded repositories are stored',
            dest='bulk_directory')
    parser.add_argument('--truncate', metavar=('trailing', 'leading'), nargs=2,
            type=parse_truncate_range,
            help='truncates the amount of leading and trailing lines',
            dest='truncate')
    parser.add_argument('assignment', metavar='assignment', nargs='?',
            type=curried_parse_assignment, help='grade this assignment')

    try:
        if len(argv) <= 1:
            parser.print_help()
            exit()

        set_home_path(Path(os.path.abspath(os.path.dirname(argv[0]))))

        args = parser.parse_args(argv[1:])

        if args.quiet:
            enter_quiet_mode()

        if args.truncate:
            set_truncate(*args.truncate)

        if args.bulk_file:
            enable_bulk_grader(args.bulk_file)

        if args.bulk_directory:
            set_bulk_grade_directory(args.bulk_directory)

        validate_options_for(args.assignment)

        if bulk_grade_mode:
            do_bulk_grading(args.assignment, baseline)
        else:
            check_assignment(args.assignment, baseline)

    finally:
        reset_state()
    def test_result_of_timed_out_test(self, mock):
        mock.side_effect = self.execute_mock

        set_home_path(Path('..'))

        with CaptureOutput() as capture:
            check_self_compilation()

            output = capture.get_output()

        for_all_test_results(output, self.check_output)
Пример #4
0
def process_arguments(argv: List[str], assignments: Set[Assignment],
                      baseline: Assignment):
    def curried_parse_assignment(assignment: str) -> Optional[Assignment]:
        return parse_assignment(assignment, assignments)

    parser = ArgumentParser(argv[0],
                            formatter_class=RawDescriptionHelpFormatter,
                            description=GRADER_SYNOPSIS,
                            epilog=list_assignments_str(assignments))

    parser.add_argument('-q',
                        action='store_true',
                        default=False,
                        help='only the grade is printed',
                        dest='quiet')
    parser.add_argument(
        '-b',
        default=None,
        metavar="<file>",
        help=
        'bulk grade assignments defined by a file with github commit links',
        dest='bulk_file')
    parser.add_argument(
        '-d',
        default=None,
        metavar="<directory>",
        help='path where all bulk graded repositories should be saved',
        dest='bulk_directory')
    parser.add_argument('assignment',
                        metavar='assignment',
                        nargs='?',
                        type=curried_parse_assignment,
                        help='The assignment to test')

    try:
        if len(argv) <= 1:
            parser.print_help()
            exit()

        set_home_path(Path(os.path.abspath(os.path.dirname(argv[0]))))

        args = parser.parse_args(argv[1:])

        if args.quiet:
            enter_quiet_mode()

        if args.bulk_file:
            enable_bulk_grader(args.bulk_file)

        if args.bulk_directory:
            set_bulk_grade_directory(args.bulk_directory)

        validate_options_for(args.assignment)

        if bulk_grade_mode:
            do_bulk_grading(args.assignment, baseline)
        else:
            check_assignment(args.assignment, baseline)

    finally:
        reset_state()