Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cccc22a

Browse files
committed
add test for pagecount getter of PdfPages
1 parent 172a494 commit cccc22a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

lib/matplotlib/tests/test_backend_pdf.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,23 @@ def test_type42():
3737
ax = fig.add_subplot(111)
3838
ax.plot([1,2,3])
3939
fig.savefig(io.BytesIO())
40+
41+
42+
@cleanup
43+
def test_multipage_pagecount():
44+
from matplotlib.backends.backend_pdf import PdfPages
45+
from io import BytesIO
46+
with PdfPages(BytesIO()) as pdf:
47+
assert pdf.get_pagecount() == 0
48+
fig = plt.figure()
49+
ax = fig.add_subplot(111)
50+
ax.plot([1, 2, 3])
51+
fig.savefig(pdf, format="pdf")
52+
assert pdf.get_pagecount() == 1
53+
pdf.savefig()
54+
assert pdf.get_pagecount() == 2
55+
56+
57+
if __name__ == '__main__':
58+
import nose
59+
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

0 commit comments

Comments
 (0)