MCPcopy Index your code
hub / github.com/danielgtaylor/python-betterproto / test_multiple_varints

Function test_multiple_varints

tests/test_streams.py:352–376  ·  view source on GitHub ↗
(compile_jar, tmp_path)

Source from the content-addressed store, hash-verified

350
351
352def test_multiple_varints(compile_jar, tmp_path):
353 single_byte = (1, b"\x01")
354 multi_byte = (123456789, b"\x95\x9A\xEF\x3A")
355 over32 = (3000000000, b"\x80\xBC\xC1\x96\x0B")
356
357 # Write two varints to the same file
358 with open(tmp_path / "py_multiple_varints.out", "wb") as stream:
359 betterproto.dump_varint(single_byte[0], stream)
360 betterproto.dump_varint(multi_byte[0], stream)
361 betterproto.dump_varint(over32[0], stream)
362
363 # Have Java read these varints and write them back
364 run_jar("multiple_varints", tmp_path)
365
366 # Read varints from Java output file
367 with open(tmp_path / "java_multiple_varints.out", "rb") as stream:
368 returned_single = betterproto.load_varint(stream)
369 returned_multi = betterproto.load_varint(stream)
370 returned_over32 = betterproto.load_varint(stream)
371 with pytest.raises(EOFError):
372 betterproto.load_varint(stream)
373
374 assert returned_single == single_byte
375 assert returned_multi == multi_byte
376 assert returned_over32 == over32
377
378
379def test_single_message(compile_jar, tmp_path):

Callers

nothing calls this directly

Calls 1

run_jarFunction · 0.85

Tested by

no test coverage detected