def test_matplotlib(self): student_code = dedent(''' import matplotlib.pyplot as plt plt.plot([1,2,3]) plt.title("My line plot") plt.show() ''') contextualize_report(student_code) student = run(student_code, filename='student.py') self.assertIn('plotting', dir(student.modules)) plt = student.modules.plotting self.assertEqual(len(plt.plots), 1)
def __init__(self, files=None, main_file='answer.py', main_code=None, user=None, assignment=None, course=None, execution=None, instructor_file='on_run.py', skip_tifa=False, skip_run=False, inputs=None, set_success=True, report=MAIN_REPORT, trace=True, threaded=True, **kwargs): super().__init__(files=files, main_file=main_file, main_code=main_code, user=user, assignment=assignment, course=course, execution=execution, instructor_file=instructor_file, report=report) self.skip_run = skip_run self.skip_tifa = skip_tifa self.trace = trace report.set_formatter(Formatter(report)) verify(report=self.report) if not skip_tifa: tifa_analysis(report=self.report) if inputs: set_input(inputs) if skip_run: student = get_sandbox(report=report) student.threaded = threaded else: if trace: start_trace() student = run(report=report, threaded=threaded) student.threaded = threaded self.fields = { 'student': student, 'resolve': resolve, 'next_section': self.next_section, 'sectional_resolve': sectional_resolve, 'show_as_hidden': show_as_hidden }
def __init__(self, files=None, main_file='answer.py', main_code=None, user=None, assignment=None, course=None, execution=None, instructor_file='on_run.py', skip_tifa=False, skip_run=False, inputs=None, set_success=True, report=MAIN_REPORT, trace=True): super().__init__(files=files, main_file=main_file, main_code=main_code, user=user, assignment=assignment, course=course, execution=execution, instructor_file=instructor_file, report=report) report.set_formatter(HtmlFormatter(report)) verify(report=self.report) if not skip_tifa: tifa_analysis(report=self.report) if inputs: set_input(inputs) if skip_run: student = get_sandbox(report=report) else: if trace: start_trace() student = run(report=report) self.fields = { 'student': student, 'resolve': resolve, 'stats_resolve': stats_resolve }
def __init__(self, code): contextualize_report(Submission({'answer.py': code})) self.student = run()