Don't repeat tests (#643)

* Don't repeat tests

* Format code
This commit is contained in:
Adrien 2025-01-03 03:01:36 +01:00 committed by GitHub
parent f41934a0e2
commit 36b5fd1495
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 39 deletions

View File

@ -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)

View File

@ -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