File: test_inkscape_extension.py

package info (click to toggle)
svgwrite 1.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 2,092 kB
  • sloc: python: 12,603; makefile: 117; sh: 5
file content (30 lines) | stat: -rw-r--r-- 875 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
# Copyright (c) 2018 Manfred Moitzi
# License: MIT License
import pytest

import svgwrite
from svgwrite.extensions import Inkscape
from svgwrite.extensions.inkscape import GROUP_MODE, LABEL

@pytest.fixture
def dwg():
    return svgwrite.Drawing('test-inkscape-extension.svg', profile='full', size=(640, 480))

def test_layer(dwg):
    inkscape = Inkscape(dwg)
    layer = inkscape.layer(label="Layer one", locked=True)
    dwg.add(layer)
    assert layer[GROUP_MODE] == 'layer'
    assert layer[LABEL] == 'Layer one'


def test_add_line_to_layer(dwg):
    inkscape = Inkscape(dwg)
    layer = inkscape.layer(label="Layer one", locked=True)
    dwg.add(layer)

    line = dwg.line((100, 100), (300, 100), stroke=svgwrite.rgb(10, 10, 16, '%'), stroke_width=10)
    layer.add(line)

    text = dwg.text('Test', insert=(100, 100), font_size=100, fill='red')
    layer.add(text)