Beispiel #1
0
def test_func():
    # type: () -> None
    s = Simple1(a_string="hello")

    s = Simple1()
    s.a_string = "Hello"
    s.a_repeated_string.append("Hello")

    s2 = Simple1.FromString(s.SerializeToString())
    assert s2.a_string == "Hello"

    s3 = Simple1()
    s3.ParseFromString(s.SerializeToString())
    assert s3.a_string == "Hello"

    s4 = Simple1()
    s4.CopyFrom(s)
    assert s4.a_string == "Hello"

    l = lower2()
    l.upper.Lower.a = 2
    assert l == lower2(upper=Upper(Lower=lower(a=2)))
def test_func() -> None:
    s = Simple1(a_string="hello")

    s = Simple1()
    s.a_string = "Hello"
    s.a_repeated_string.append("Hello")

    s2 = Simple1.FromString(s.SerializeToString())
    assert s2.a_string == "Hello"
    assert s2.A_STRING_FIELD_NUMBER == 1
    assert s2.USER_ID_FIELD_NUMBER == 21

    s3 = Simple1()
    s3.ParseFromString(s.SerializeToString())
    assert s3.a_string == "Hello"

    s4 = Simple1()
    s4.CopyFrom(s)
    assert s4.a_string == "Hello"

    l = lower2()
    l.upper.Lower.a = 2
    assert l == lower2(upper=Upper(Lower=lower(a=2)))
Beispiel #3
0
from testproto.test_pb2 import (
    DESCRIPTOR,
    Extensions1,
    Extensions2,
    FOO,
    Simple1,
    Simple2,
)
from testproto.test3_pb2 import OuterEnum, OuterMessage3, SimpleProto3
from testproto.dot.com.test_pb2 import TestMessage
from test.test_generated_mypy import Email, UserId

s = Simple1()
s.a_string = "Hello"

s2 = Simple1.FromString(s.SerializeToStringg())  # E:2.7 E:3.8

s3 = Simple1()
s3.ParseFromString(s)  # E:2.7 E:3.8

s4 = Simple1()
s4.CopyFrom(s.SerializeToString())  # E:2.7 E:3.8

s5 = Simple1()
l = []  # type: List[int]
l.extend(s5.a_repeated_string)  # E:2.7 E:3.8

tm = TestMessage(foo=55)  # E:2.7 E:3.8

e = FOO
e = 3  # E:2.7 E:3.8