parent
f41934a0e2
commit
36b5fd1495
@ -4,17 +4,6 @@ import sys
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
def pytest_addoption(parser):
|
|
||||||
parser.addoption(
|
|
||||||
"--repeat", type=int, default=1, help="repeat the operation multiple times"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session")
|
|
||||||
def repeat(request):
|
|
||||||
return request.config.getoption("repeat")
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def reset_sys_path():
|
def reset_sys_path():
|
||||||
original = copy.deepcopy(sys.path)
|
original = copy.deepcopy(sys.path)
|
||||||
|
@ -174,10 +174,9 @@ def test_message_equality(test_data: TestData) -> None:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("test_data", test_cases.messages_with_json, indirect=True)
|
@pytest.mark.parametrize("test_data", test_cases.messages_with_json, indirect=True)
|
||||||
def test_message_json(repeat, test_data: TestData) -> None:
|
def test_message_json(test_data: TestData) -> None:
|
||||||
plugin_module, _, json_data = test_data
|
plugin_module, _, json_data = test_data
|
||||||
|
|
||||||
for _ in range(repeat):
|
|
||||||
for sample in json_data:
|
for sample in json_data:
|
||||||
if sample.belongs_to(test_input_config.non_symmetrical_json):
|
if sample.belongs_to(test_input_config.non_symmetrical_json):
|
||||||
continue
|
continue
|
||||||
@ -198,16 +197,15 @@ def test_service_can_be_instantiated(test_data: TestData) -> None:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("test_data", test_cases.messages_with_json, indirect=True)
|
@pytest.mark.parametrize("test_data", test_cases.messages_with_json, indirect=True)
|
||||||
def test_binary_compatibility(repeat, test_data: TestData) -> None:
|
def test_binary_compatibility(test_data: TestData) -> None:
|
||||||
plugin_module, reference_module, json_data = test_data
|
plugin_module, reference_module, json_data = test_data
|
||||||
|
|
||||||
for sample in json_data:
|
for sample in json_data:
|
||||||
reference_instance = Parse(sample.json, reference_module().Test())
|
reference_instance = Parse(sample.json, reference_module().Test())
|
||||||
reference_binary_output = reference_instance.SerializeToString()
|
reference_binary_output = reference_instance.SerializeToString()
|
||||||
|
|
||||||
for _ in range(repeat):
|
plugin_instance_from_json: betterproto.Message = plugin_module.Test().from_json(
|
||||||
plugin_instance_from_json: betterproto.Message = (
|
sample.json
|
||||||
plugin_module.Test().from_json(sample.json)
|
|
||||||
)
|
)
|
||||||
plugin_instance_from_binary = plugin_module.Test.FromString(
|
plugin_instance_from_binary = plugin_module.Test.FromString(
|
||||||
reference_binary_output
|
reference_binary_output
|
||||||
|
Loading…
x
Reference in New Issue
Block a user