|
|
|
@ -15,6 +15,7 @@
|
|
|
|
|
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
|
|
|
|
|
|
|
|
|
from io import BytesIO
|
|
|
|
|
import logging
|
|
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
@ -137,6 +138,7 @@ def test_simple_message():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_validate_enum(caplog):
|
|
|
|
|
caplog.set_level(logging.INFO)
|
|
|
|
|
# round-trip of a valid value
|
|
|
|
|
msg = EnumMessageMoreValues(enum=0)
|
|
|
|
|
buf = BytesIO()
|
|
|
|
@ -154,7 +156,7 @@ def test_validate_enum(caplog):
|
|
|
|
|
|
|
|
|
|
assert len(caplog.records) == 1
|
|
|
|
|
record = caplog.records.pop(0)
|
|
|
|
|
assert record.levelname == "WARNING"
|
|
|
|
|
assert record.levelname == "INFO"
|
|
|
|
|
assert record.getMessage() == "Value 19 unknown for type t"
|
|
|
|
|
|
|
|
|
|
msg.enum = 3
|
|
|
|
@ -165,7 +167,7 @@ def test_validate_enum(caplog):
|
|
|
|
|
|
|
|
|
|
assert len(caplog.records) == 1
|
|
|
|
|
record = caplog.records.pop(0)
|
|
|
|
|
assert record.levelname == "WARNING"
|
|
|
|
|
assert record.levelname == "INFO"
|
|
|
|
|
assert record.getMessage() == "Value 3 unknown for type t"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -182,12 +184,14 @@ def test_repeated():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_enum_in_repeated(caplog):
|
|
|
|
|
caplog.set_level(logging.INFO)
|
|
|
|
|
|
|
|
|
|
msg = RepeatedFields(enumlist=[0, 1, 2, 3])
|
|
|
|
|
buf = BytesIO()
|
|
|
|
|
protobuf.dump_message(buf, msg)
|
|
|
|
|
assert len(caplog.records) == 2
|
|
|
|
|
for record in caplog.records:
|
|
|
|
|
assert record.levelname == "WARNING"
|
|
|
|
|
assert record.levelname == "INFO"
|
|
|
|
|
assert "unknown for type t" in record.getMessage()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|