Esempio n. 1
0
def test_value_types(entity, processor):
    attribs = DXFNamespace(processor, entity)
    attribs.handle = None  # None is always accepted, attribute is ignored at export
    assert attribs.handle is None
    attribs.handle = 'XYZ'
    assert attribs.handle == 'XYZ', 'handle is just a string'
    attribs.handle = 123
    assert attribs.handle == '123', 'handle is just a string'
    with pytest.raises(ValueError):
        attribs.color = 'xxx'

    attribs.start = (1, 2, 3)  # type: Vector
    assert attribs.start == (1, 2, 3)
    assert attribs.start.x == 1
    assert attribs.start.y == 2
    assert attribs.start.z == 3
def test_value_types(entity, processor):
    attribs = DXFNamespace(processor, entity)
    attribs.handle = (
        None  # None is always accepted, attribute is ignored at export
    )
    assert attribs.handle is None
    attribs.handle = "XYZ"
    assert attribs.handle == "XYZ", "handle is just a string"
    attribs.handle = 123
    assert attribs.handle == "123", "handle is just a string"
    with pytest.raises(ValueError):
        attribs.color = "xxx"

    attribs.start = (1, 2, 3)  # type: Vec3
    assert attribs.start == (1, 2, 3)
    assert attribs.start.x == 1
    assert attribs.start.y == 2
    assert attribs.start.z == 3
Esempio n. 3
0
def test_set_values(entity, processor):
    attribs = DXFNamespace(processor, entity)
    attribs.handle = 'CDEF'
    assert attribs.handle == 'CDEF'
    attribs.set('owner', 'DADA')
    assert attribs.owner == 'DADA'
    # set new attribute
    attribs.color = 7
    assert attribs.color == 7
    attribs.set('linetype', 'DOT')
    assert attribs.linetype == 'DOT'
    # attribute has to a valid DXF attribute
    with pytest.raises(DXFAttributeError):
        attribs.hallo = 0
    with pytest.raises(DXFAttributeError):
        attribs.set('hallo', 0)
def test_set_values(entity, processor):
    attribs = DXFNamespace(processor, entity)
    attribs.handle = "CDEF"
    assert attribs.handle == "CDEF"
    attribs.set("owner", "DADA")
    assert attribs.owner == "DADA"
    # set new attribute
    attribs.color = 7
    assert attribs.color == 7
    attribs.set("linetype", "DOT")
    assert attribs.linetype == "DOT"
    # attribute has to a valid DXF attribute
    with pytest.raises(DXFAttributeError):
        attribs.hallo = 0
    with pytest.raises(DXFAttributeError):
        attribs.set("hallo", 0)
 def dxf(self, processor, entity):
     ns = DXFNamespace(processor, entity)
     ns.color = 7
     ns.handle = "ABBA"
     ns.owner = "FEFE"
     return ns