File: test_drawing_matplotlib_backend.py

package info (click to toggle)
ezdxf 0.18.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 46,952 kB
  • sloc: python: 158,141; javascript: 166; cpp: 138; makefile: 116; lisp: 20
file content (25 lines) | stat: -rw-r--r-- 673 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
# Created: 06.2020
# Copyright (c) 2020, Matthew Broadway
# License: MIT License
import pytest

plt = pytest.importorskip("matplotlib.pyplot")

from ezdxf.addons.drawing.matplotlib import MatplotlibBackend


@pytest.fixture()
def backend():
    fig, ax = plt.subplots()
    return MatplotlibBackend(ax)


def test_get_text_width(backend):
    assert backend.get_text_line_width(
        "   abc", 100
    ) > backend.get_text_line_width("abc", 100)
    assert backend.get_text_line_width(
        "  abc ", 100
    ) == backend.get_text_line_width("  abc", 100)
    assert backend.get_text_line_width("   ", 100) == 0
    assert backend.get_text_line_width("  ", 100) == 0