Support deprecated message and fields (#126)
This commit is contained in:
committed by
GitHub
parent
beafc812ff
commit
0cd9510b54
4
tests/inputs/deprecated/deprecated.json
Normal file
4
tests/inputs/deprecated/deprecated.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"v": 10,
|
||||
"value": 10
|
||||
}
|
9
tests/inputs/deprecated/deprecated.proto
Normal file
9
tests/inputs/deprecated/deprecated.proto
Normal file
@@ -0,0 +1,9 @@
|
||||
syntax = "proto3";
|
||||
|
||||
// Some documentation about the Test message.
|
||||
message Test {
|
||||
// Some documentation about the value.
|
||||
option deprecated = true;
|
||||
int32 v = 1 [deprecated=true];
|
||||
int32 value = 2;
|
||||
}
|
4
tests/inputs/deprecated_field/deprecated_field.json
Normal file
4
tests/inputs/deprecated_field/deprecated_field.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"v": 10,
|
||||
"value": 10
|
||||
}
|
8
tests/inputs/deprecated_field/deprecated_field.proto
Normal file
8
tests/inputs/deprecated_field/deprecated_field.proto
Normal file
@@ -0,0 +1,8 @@
|
||||
syntax = "proto3";
|
||||
|
||||
// Some documentation about the Test message.
|
||||
message Test {
|
||||
// Some documentation about the value.
|
||||
int32 v = 1 [deprecated=true];
|
||||
int32 value = 2;
|
||||
}
|
26
tests/test_deprecated.py
Normal file
26
tests/test_deprecated.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import pytest
|
||||
|
||||
from tests.output_betterproto.deprecated import Test as DeprecatedMessageTest
|
||||
from tests.output_betterproto.deprecated_field import Test as DeprecatedFieldTest
|
||||
|
||||
|
||||
def test_deprecated_message():
|
||||
with pytest.deprecated_call():
|
||||
DeprecatedMessageTest(value=10)
|
||||
|
||||
|
||||
def test_deprecated_message_with_deprecated_field():
|
||||
with pytest.warns(None) as record:
|
||||
DeprecatedMessageTest(v=10, value=10)
|
||||
assert len(record) == 2
|
||||
|
||||
|
||||
def test_deprecated_field_warning():
|
||||
with pytest.deprecated_call():
|
||||
DeprecatedFieldTest(v=10, value=10)
|
||||
|
||||
|
||||
def test_deprecated_field_no_warning():
|
||||
with pytest.warns(None) as record:
|
||||
DeprecatedFieldTest(value=10)
|
||||
assert not record
|
Reference in New Issue
Block a user