| 162 | |
| 163 | |
| 164 | def test_bbox(): |
| 165 | fig, ax = plt.subplots() |
| 166 | with io.BytesIO() as buf: |
| 167 | fig.savefig(buf, format='eps') |
| 168 | buf = buf.getvalue() |
| 169 | |
| 170 | bb = re.search(b'^%%BoundingBox: (.+) (.+) (.+) (.+)$', buf, re.MULTILINE) |
| 171 | assert bb |
| 172 | hibb = re.search(b'^%%HiResBoundingBox: (.+) (.+) (.+) (.+)$', buf, |
| 173 | re.MULTILINE) |
| 174 | assert hibb |
| 175 | |
| 176 | for i in range(1, 5): |
| 177 | # BoundingBox must use integers, and be ceil/floor of the hi res. |
| 178 | assert b'.' not in bb.group(i) |
| 179 | assert int(bb.group(i)) == pytest.approx(float(hibb.group(i)), 1) |
| 180 | |
| 181 | |
| 182 | @needs_usetex |