Testing of existence of a repeated field in a protobuff message
<p>I have a google protobuf message:</p>

<pre><code>message Foo {
  required int bar = 1;
}
</code></pre>

<p>I know that in order to test the fields of message, we can use:</p>

<pre><code>foo.bar = 1
assert foo.HasField("bar")
</code></pre>

<p>However "HasField" doesn't work for repeated field types.
How to test for existence of field for "repeated type" of fields?</p>

<pre><code>message Foo {
  repeated int bar = 1;
}
</code></pre>

<p>You could try to test the lenght of the repeated field:</p>

<pre><code>assert len(foo.bar) == 0
</code></pre>

python unit-testing protocol-buffers