Skip to content

Commit

Permalink
test exc
Browse files Browse the repository at this point in the history
  • Loading branch information
jjaakola-aiven committed Jul 24, 2024
1 parent a226610 commit 0ddee89
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ jobs:
env:
COVERAGE_FILE: ".coverage.${{ matrix.python-version }}"
PYTEST_ARGS: "--cov=karapace --cov-append"
- run: make integration-tests
env:
COVERAGE_FILE: ".coverage.${{ matrix.python-version }}"
PYTEST_ARGS: "--cov=karapace --cov-append --random-order"

- name: Archive logs
uses: actions/upload-artifact@v4
Expand Down
14 changes: 7 additions & 7 deletions karapace/protobuf/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,13 @@ def writer_process(
# Writing happens in the forked process, catch is broad so exception will get communicated
# back to calling process.
except Exception as bare_exception: # pylint: disable=broad-exception-caught
try:
raise ProtobufTypeException(writer_schema, datum) from bare_exception
except ProtobufTypeException as protobuf_exception:
writer_queue.put(protobuf_exception)
raise protobuf_exception
except BaseException as base_exception: # pylint: disable=broad-exception-caught
writer_queue.put(base_exception)
#try:
# raise ProtobufTypeException(writer_schema, datum) from bare_exception
#except ProtobufTypeException as protobuf_exception:
# writer_queue.put(protobuf_exception)
# raise protobuf_exception
writer_queue.put(bare_exception)
raise bare_exception
writer_queue.put(class_instance.SerializeToString())


Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_protobuf_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,14 @@ async def test_serialization_fails(default_config_path: Path):
mock_protobuf_registry_client.get_schema.return_value = get_latest_schema_future

serializer = await make_ser_deser(default_config_path, mock_protobuf_registry_client)
with pytest.raises(InvalidMessageSchema):
with pytest.raises(RuntimeError):
schema = await serializer.get_schema_for_subject("top")
await serializer.serialize(schema, test_fail_objects_protobuf[0])

assert mock_protobuf_registry_client.method_calls == [call.get_schema("top")]
mock_protobuf_registry_client.reset_mock()

with pytest.raises(InvalidMessageSchema):
with pytest.raises(KeyError):
schema = await serializer.get_schema_for_subject("top")
await serializer.serialize(schema, test_fail_objects_protobuf[1])

Expand Down

0 comments on commit 0ddee89

Please sign in to comment.