def test_show(is_matplotlib_cleared): assert is_matplotlib_cleared code = """\ import matplotlib.pyplot as plt data = [1, 2] plt.plot(data) plt.show() """ expected_report = """\ create_image 0 0 image='...' """ canvas = Canvas(width=100, height=100) tracer = CodeTracer(canvas) report = tracer.trace_turtle(code) assert expected_report == replace_image(report)
def test_turtle(self): # SETUP code = """\ __live_turtle__.forward(100) """ expected_report = """\ create_line 0 0 100 0 fill='black' pensize=1 """ tracer = CodeTracer() # EXEC report = tracer.trace_turtle(code) # VERIFY self.assertEqual(expected_report.splitlines(), report.splitlines())
def test_turtle(self): # SETUP code = """\ from turtle import * forward(100) """ expected_report = """\ create_line 0 0 100 0 fill='black' pensize=1 """ tracer = CodeTracer() # EXEC report = tracer.trace_turtle(code) # VERIFY self.assertReportEqual(expected_report, report)