| 377 | |
| 378 | |
| 379 | def test_single_message(compile_jar, tmp_path): |
| 380 | # Write message to file |
| 381 | with open(tmp_path / "py_single_message.out", "wb") as stream: |
| 382 | oneof_example.dump(stream) |
| 383 | |
| 384 | # Have Java read and return the message |
| 385 | run_jar("single_message", tmp_path) |
| 386 | |
| 387 | # Read and check the returned message |
| 388 | with open(tmp_path / "java_single_message.out", "rb") as stream: |
| 389 | returned = oneof.Test().load(stream, len(bytes(oneof_example))) |
| 390 | assert stream.read() == b"" |
| 391 | |
| 392 | assert returned == oneof_example |
| 393 | |
| 394 | |
| 395 | def test_multiple_messages(compile_jar, tmp_path): |