File: test_none_ascii_read_write.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 (31 lines) | stat: -rw-r--r-- 856 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
#  Copyright (c) 2020, Manfred Moitzi
#  License: MIT License
import pytest
import os
import ezdxf
from ezdxf.lldxf.const import versions_supported_by_new

NONE_ASCII = "äöüÄÖÜß±ØáàÀÁóòÓÒéèÉÈ"


@pytest.fixture(params=versions_supported_by_new)
def doc(request):
    return ezdxf.new(request.param)


def test_write_and_read_unicode(doc, tmpdir):
    msp = doc.modelspace()
    msp.add_text(NONE_ASCII)
    filename = str(tmpdir.join("none_ascii_%s.dxf" % doc.dxfversion))
    try:
        doc.saveas(filename)
    except ezdxf.DXFError as e:
        pytest.fail(
            "DXFError: {0} for DXF version {1}".format(str(e), doc.dxfversion)
        )
    assert os.path.exists(filename)

    doc = ezdxf.readfile(filename)
    text = doc.modelspace().query("TEXT")
    assert len(text) == 1
    assert text[0].dxf.text == NONE_ASCII