Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-1241

BSON Corpus Test doesn't thoroughly test JSON generation

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Tests
    • Labels:
      None

      Description

      Here:

      https://github.com/mongodb/specifications/blob/master/source/bson-corpus/bson-corpus.rst#testing-validity

      It specifies the test should do:

              assert encode_extjson(decode_bson(B)) == cE             # B->cE
              assert encode_extjson(decode_extjson(E)) == cE          # E->cE
      

      But in test_bson_corpus.py:

      self.assertEqual(
          json.loads(encode_extjson(decode_bson(B))),
          normalized_cE)
       
      self.assertEqual(
          json.loads(encode_extjson(decode_extjson(E))),
          normalized_cE)
      

      This isn't quite right. The Python test thoroughly tests parsing but not generation. E.g. it doesn't prove that all ints are generated as $numberInt or $numberLong, the test can pass even with bare ints like "1", which are not up to spec.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              luke.lovett Luke Lovett
              Reporter:
              jesse A. Jesse Jiryu Davis
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: