2018-05-17 15:57:39 +00:00
|
|
|
def test_matplotlib(selenium):
|
|
|
|
selenium.load_package("matplotlib")
|
2018-05-17 18:30:52 +00:00
|
|
|
selenium.run("from matplotlib import pyplot as plt")
|
2018-08-20 17:10:32 +00:00
|
|
|
selenium.run("plt.figure()")
|
2018-05-17 18:30:52 +00:00
|
|
|
selenium.run("x = plt.plot([1,2,3])")
|
2018-05-21 18:15:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_svg(selenium):
|
|
|
|
selenium.load_package("matplotlib")
|
|
|
|
selenium.run("from matplotlib import pyplot as plt")
|
2018-08-20 17:10:32 +00:00
|
|
|
selenium.run("plt.figure()")
|
2018-05-21 18:15:50 +00:00
|
|
|
selenium.run("x = plt.plot([1,2,3])")
|
|
|
|
selenium.run("import io")
|
|
|
|
selenium.run("fd = io.BytesIO()")
|
|
|
|
selenium.run("plt.savefig(fd, format='svg')")
|
|
|
|
content = selenium.run("fd.getvalue().decode('utf8')")
|
|
|
|
assert len(content) == 15752
|
|
|
|
assert content.startswith("<?xml")
|
2019-01-25 14:33:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_pdf(selenium):
|
|
|
|
selenium.load_package("matplotlib")
|
|
|
|
selenium.run("from matplotlib import pyplot as plt")
|
|
|
|
selenium.run("plt.figure()")
|
|
|
|
selenium.run("x = plt.plot([1,2,3])")
|
|
|
|
selenium.run("import io")
|
|
|
|
selenium.run("fd = io.BytesIO()")
|
2019-01-28 16:04:52 +00:00
|
|
|
selenium.run("plt.savefig(fd, format='pdf')")
|
2019-01-25 14:33:52 +00:00
|
|
|
content = selenium.run("fd.getvalue()")
|
2019-01-28 20:06:21 +00:00
|
|
|
assert len(content) == 5559
|