Esempio n. 1
0
    def test_concurrent_machines(self, mock):
        mock.side_effect = self.insert_assignment_stub

        with patch('lib.grade.print_loud') as print_mock:
            main([sys.argv[0], 'concurrent-machines'])

            print_mock.assert_any_call('2', end='')
Esempio n. 2
0
    def test_concurrent_machines(self, mock):
        mock.side_effect = self.insert_assignment_stub

        with CaptureOutput() as capture:
            main([sys.argv[0], 'concurrent-machines'])

            self.assertIs('2', capture.get_loud_output())
Esempio n. 3
0
    def test_instruction(self, mock):
        mock.side_effect = self.execute_mock

        with CaptureOutput() as capture:
            for assignment in assignments:
                grader.main([sys.argv[0], assignment.name])

        for_all_test_results(capture.get_output(), self.check_encoding_results)
Esempio n. 4
0
    def test_default_grade(self, mock):
        assignments = map(lambda a: a.name, grader.assignments)

        mock.side_effect = self.print_grade

        for assignment in assignments:
            self.current_assignment = assignment

            grader.main(['grader/self.py', '-q', assignment])
Esempio n. 5
0
    def test_default_grade(self, mock):
        assignments = list(
            map(lambda t: grader.name(t), grader.assignments[1:]))

        mock.side_effect = self.print_grade

        for assignment in assignments:
            self.current_assignment = assignment

            grader.main(['grader/self.py', '-q', assignment])
Esempio n. 6
0
    def test_default_grade(self):
        assignments = list(map(lambda t: grader.name(t), grader.assignments[1:]))

        with patch('lib.grade.print_loud') as mock:
            mock.side_effect = self.print_loud
            
            for assignment in assignments:
                self.current_assignment = assignment

                grader.main(['grader/self.py', '-q', assignment])
Esempio n. 7
0
    def test_default_grade(self, mock):
        without_baseline = grader.assignments.difference(grader.baseline_assignments)
        assignments = map(lambda a: a.name, without_baseline)

        mock.side_effect = self.print_grade

        for assignment in assignments:
            self.current_assignment = assignment

            grader.main(['grader/self.py', '-q', assignment])
Esempio n. 8
0
def run_compilable_assignments(prev=None, after=None):
    for assignment in compilable_assignments:
        if prev != None:
            prev(assignment)

        with CaptureOutput() as capture:
            grader.main([sys.argv[0], name(assignment)])

            output = capture.get_output()

            if after != None:
                after(output)
Esempio n. 9
0
def run_compilable_assignments(prev=None, after=None):
    for assignment in compilable_assignments:
        if prev != None:
            prev(assignment)
        
        with Console() as console:
            grader.main([sys.argv[0], name(assignment)])

            output = console.get_output()

            if after != None:
                after(output)

        reload(grader)
Esempio n. 10
0
    def test_instruction(self, mock):
        mock.side_effect = self.execute_mock

        output = ''

        for assignment in assignments:
            with Console() as console:
                grader.main([sys.argv[0], name(assignment)])

                output = output + console.get_output()

            reload(grader)

        for_all_test_results(output, self.check_encoding_results)
 def test_baseline_execution_order(self):
     with CaptureOutput():
         grader.main([sys.argv[0], list(self.assignments)[0].name])