File: test_output.py

package info (click to toggle)
fpdf2 2.8.7-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 114,352 kB
  • sloc: python: 50,410; sh: 133; makefile: 12
file content (27 lines) | stat: -rw-r--r-- 728 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from filecmp import cmp

import fpdf
import pytest

from test.conftest import assert_same_file


def test_repeated_calls_to_output(tmp_path):
    pdf = fpdf.FPDF()
    pdf.output(tmp_path / "empty.pdf")
    pdf.output(tmp_path / "empty2.pdf")
    assert cmp(tmp_path / "empty.pdf", tmp_path / "empty2.pdf")


def test_deprecation_warning(tmp_path):
    pdf = fpdf.FPDF()
    with pytest.warns(DeprecationWarning) as record:
        # pylint: disable=unexpected-keyword-arg
        pdf.output(name=tmp_path / "empty.pdf", dest="F")
    assert len(record) == 1
    assert_same_file(record[0].filename, __file__)


def test_save_to_absolute_path(tmp_path):
    pdf = fpdf.FPDF()
    pdf.output((tmp_path / "empty.pdf").absolute())