Some checks and tests are performed based on Python data types. Python and YANG, however, have different equality semantics for certain data types. One such example are integers and booleans. In Python, the following comparison yields True.
>>> {"boolean": 1} == {"boolean": True}
True
While in a YANG, according to https://datatracker.ietf.org/doc/html/rfc7951#section-6.3, this would not be the case.
As many tests are based on Python's equality operator (e.g. assertEqual()), there is a potential gag in test coverage. Here is a concrete example:
Run original json-serialize tests
tox -- tests/serialise/json-serialise/
Modify the golden sample to violate https://datatracker.ietf.org/doc/html/rfc7951#section-6.3 (e.g. change the "boolean" leaf node from "true" to "1"), print the entire file, and rerun the test.
# The following commands require the jq and sponge tools
jq '.c1.l1."1".boolean=1' tests/serialise/json-serialise/json/expected-output.json | sponge tests/serialise/json-serialise/json/expected-output.json
jq . tests/serialise/json-serialise/json/expected-output.json
tox -- tests/serialise/json-serialise/
Despite the modification, tests/serialise/json-serialise/ returns no issues.
Some checks and tests are performed based on Python data types. Python and YANG, however, have different equality semantics for certain data types. One such example are integers and booleans. In Python, the following comparison yields True.
While in a YANG, according to https://datatracker.ietf.org/doc/html/rfc7951#section-6.3, this would not be the case.
As many tests are based on Python's equality operator (e.g. assertEqual()), there is a potential gag in test coverage. Here is a concrete example:
Run original json-serialize tests
Modify the golden sample to violate https://datatracker.ietf.org/doc/html/rfc7951#section-6.3 (e.g. change the "boolean" leaf node from "true" to "1"), print the entire file, and rerun the test.
Despite the modification,
tests/serialise/json-serialise/returns no issues.