示例#1
0
def test_type_not_in_defaults_fails():
    # If `type` is not set in defaults, it must be set for each properties
    data = """
class: Sound
properties:
    - name: p1
    - name: p2
"""

    with pytest.raises(ParseError):
        parse_definition_string(data)
示例#2
0
def test_type_set_in_defaults_field():
    # If `type` is set in defaults, it does not have to be set for each properties
    data = """
class: Sound
defaults:
    type: qreal
properties:
    - name: p1
    - name: p2
"""

    dct = parse_definition_string(data)
    assert dct["class"] == "Sound"
示例#3
0
def test_load_ok():
    data = """
class: Person
properties:
- name: firstName
  type: QString
- name: lastName
  type: QString
- name: birthDate
  type: QDateTime
"""

    dct = parse_definition_string(data)
    assert dct["class"] == "Person"
示例#4
0
文件: main.py 项目: agateau/qpropgen
def load_definition_file(definition_filepath):
    try:
        with open(definition_filepath) as f:
            return parse_definition_string(f.read())
    except Exception as exc:
        raise QPropgenError(f"Failed to read {definition_filepath}: {exc}")
示例#5
0
def test_invalid_definition_file():
    data = "clas: Person"
    with pytest.raises(ParseError):
        parse_definition_string(data)