File: test_714_mleader_render_engine.py

package info (click to toggle)
ezdxf 1.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 104,528 kB
  • sloc: python: 182,341; makefile: 116; lisp: 20; ansic: 4
file content (41 lines) | stat: -rw-r--r-- 1,050 bytes parent folder | download | duplicates (2)
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
#  Copyright (c) 2021, Manfred Moitzi
#  License: MIT License

import pytest
import ezdxf
from ezdxf.math import Vec2
from ezdxf.render import mleader
from ezdxf.entities import MText, MultiLeader, Insert


@pytest.fixture(scope="module")
def doc():
    return ezdxf.new()


def make_multi_leader(doc) -> MultiLeader:
    style = doc.mleader_styles.get("Standard")
    ml = MultiLeader.new(doc=doc)
    ml.dxf.style_handle = style.dxf.handle
    return ml


class TestRenderEngine:
    """The RenderEngine renders DXF primitives from a MULTILEADER entity."""

    @pytest.fixture
    def ml_mtext(self, doc):
        ml = make_multi_leader(doc)
        builder = mleader.MultiLeaderMTextBuilder(ml)
        builder.set_content("line")
        builder.build(insert=Vec2(0, 0))
        return ml

    def test_add_mtext_content(self, ml_mtext):
        engine = mleader.RenderEngine(ml_mtext, ml_mtext.doc)
        engine.add_mtext_content()
        assert isinstance(engine.entities[0], MText)


if __name__ == "__main__":
    pytest.main([__file__])