File: test_drawing_qt_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 (42 lines) | stat: -rw-r--r-- 1,144 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
# Copyright (c) 2020-2021, Matthew Broadway
# License: MIT License
import pytest
import sys

pytest.importorskip("PySide6")
from ezdxf.addons.xqt import QtWidgets as qw
from ezdxf.addons.drawing.pyqt import PyQtBackend

WIN = sys.platform == "win32"
PY310 = sys.version_info[:2] == (3, 10)
_app = None


@pytest.fixture
def backend():
    global _app
    _app = qw.QApplication([])
    scene = qw.QGraphicsScene()
    return PyQtBackend(scene)


# Error Message:
# RuntimeError: Please destroy the QApplication singleton before creating a new
# QApplication instance.
#
# ezdxf "view" command works as expected!
# Works if launched in PyCharm, but not if launched by command line
# "pytest ..." ???

@pytest.mark.skip(
    reason="Does not work for CPython 3.10 & PySide6",
)
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