This commit is contained in:
Willi Ballenthin
2023-03-23 10:58:13 +01:00
parent 1044709803
commit 49ff9d5a7c
2 changed files with 7 additions and 2 deletions

View File

@@ -744,5 +744,6 @@ def main(argv=None):
print(proto_doc)
if __name__ == "__main__":
main()

View File

@@ -319,14 +319,18 @@ def assert_round_trip(doc: rd.ResultDocument):
# which works thanks to pydantic model equality.
assert one == two
# second by showing their protobuf representations are the same.
assert capa.render.proto.doc_to_pb2(one).SerializeToString(deterministic=True) == capa.render.proto.doc_to_pb2(two).SerializeToString(deterministic=True)
assert capa.render.proto.doc_to_pb2(one).SerializeToString(deterministic=True) == capa.render.proto.doc_to_pb2(
two
).SerializeToString(deterministic=True)
# now show that two different versions are not equal.
three = copy.deepcopy(two)
three.meta.__dict__.update({"version": "0.0.0"})
assert one.meta.version != three.meta.version
assert one != three
assert capa.render.proto.doc_to_pb2(one).SerializeToString(deterministic=True) != capa.render.proto.doc_to_pb2(three).SerializeToString(deterministic=True)
assert capa.render.proto.doc_to_pb2(one).SerializeToString(deterministic=True) != capa.render.proto.doc_to_pb2(
three
).SerializeToString(deterministic=True)
@pytest.mark.parametrize(