def test_structEquality(): a = TopLevelStruct(required='bye', second_level=SecondLevelStruct(deeper_required_prop='ciao')) b = TopLevelStruct(required='hello', second_level=1), c = TopLevelStruct(required='hello', second_level=1), d = SecondLevelStruct(deeper_required_prop='exists') assert a != b assert b == c assert a != 5 assert a != d
def test_structEquality(): a = TopLevelStruct( required="bye", second_level=SecondLevelStruct(deeper_required_prop="ciao") ) b = (TopLevelStruct(required="hello", second_level=1),) c = (TopLevelStruct(required="hello", second_level=1),) d = SecondLevelStruct(deeper_required_prop="exists") assert a != b assert b == c assert a != 5 assert a != d
def test_passStructsInVariadic(): output = StructPassing.how_many_var_args_did_i_pass( 123, TopLevelStruct(required='hello', second_level=1), TopLevelStruct( required='bye', second_level=SecondLevelStruct(deeper_required_prop='ciao'))) assert output == 2
def test_passStructsInVariadic(): output = StructPassing.how_many_var_args_did_i_pass( 123, TopLevelStruct(required="hello", second_level=1), TopLevelStruct( required="bye", second_level=SecondLevelStruct(deeper_required_prop="ciao") ), ) assert output == 2
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'))"