File: test_deprecation_warnings.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 (49 lines) | stat: -rw-r--r-- 1,180 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import pytest

from pathlib import Path

from fpdf import FPDF

HERE = Path(__file__).resolve().parent


def test_TitleStyle_deprecation():
    # pylint: disable=import-outside-toplevel
    with pytest.warns(DeprecationWarning):
        from fpdf import TitleStyle

        TitleStyle()

    with pytest.warns(DeprecationWarning):
        from fpdf.fonts import TitleStyle

        TitleStyle()


def test_add_font_uni_deprecation():
    pdf = FPDF()

    with pytest.warns(DeprecationWarning) as record:
        # pylint: disable=unexpected-keyword-arg
        pdf.add_font(
            "DejaVu",
            "",
            HERE.parent / "fonts" / "DejaVuSans.ttf",
            uni=True,
        )
    assert (
        str(record[0].message)
        == '"uni" parameter is deprecated since v2.5.1 and will be removed in a future release'
    )


def test_output_dest_deprecation():
    pdf = FPDF()

    with pytest.warns(DeprecationWarning) as record:
        # pylint: disable=unexpected-keyword-arg
        pdf.output(dest="S")
    assert (
        str(record[0].message)
        == '"dest" parameter is deprecated since v2.2.0 and will be removed in a future release'
    )