コード例 #1
0
def test_passNestedScalar():
    output = StructPassing.round_trip(123,
            required='hello',
            second_level=5)

    assert output.required == 'hello'
    assert output.optional is None
    assert output.second_level == 5
コード例 #2
0
def test_passNestedStruct():
    output = StructPassing.round_trip(123,
            required='hello',
            second_level=SecondLevelStruct(deeper_required_prop='exists'))

    assert output.required == 'hello'
    assert output.optional is None
    assert output.second_level.deeper_required_prop == 'exists'

    # Test stringification
    # Dicts are ordered in Python 3.7+, so this is fine: https://mail.python.org/pipermail/python-dev/2017-December/151283.html
    assert str(output) == "TopLevelStruct(required='hello', second_level=SecondLevelStruct(deeper_required_prop='exists'))"