question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fix remaining unit tests

See original GitHub issue

Here is a list of failing tests and their status:

============================ FAILURES =============================
________________ UltraJSONTests.testEncodeSymbols _________________

self = <test_ujson.UltraJSONTests testMethod=testEncodeSymbols>

    def testEncodeSymbols(self):
        s = '\u273f\u2661\u273f'  # ✿♡✿
        encoded = hyperjson.dumps(s)
        encoded_json = hyperjson.dumps(s)
>       self.assertEqual(len(encoded), len(s) * 6 + 2)  # 6 characters + quotes
E       AssertionError: 5 != 20

hyperjson/tests/test_ujson.py:229: AssertionError
_______________ UltraJSONTests.testEncodeUnicodeBMP _______________

self = <test_ujson.UltraJSONTests testMethod=testEncodeUnicodeBMP>

    def testEncodeUnicodeBMP(self):
        s = '\U0001f42e\U0001f42e\U0001F42D\U0001F42D'  # 🐮🐮🐭🐭
        encoded = hyperjson.dumps(s)
        encoded_json = hyperjson.dumps(s)

        if len(s) == 4:
>           self.assertEqual(len(encoded), len(s) * 12 + 2)
E           AssertionError: 6 != 50

hyperjson/tests/test_ujson.py:204: AssertionError
_____________ UltraJSONTests.test_ReadBadObjectSyntax _____________

self = <test_ujson.UltraJSONTests testMethod=test_ReadBadObjectSyntax>

    def test_ReadBadObjectSyntax(self):
        input = '{"age", 44}'
>       self.assertRaises(ValueError, hyperjson.loads, input)
E       _hyperjson.JSONDecodeError: Value: "{\"age\", 44}", Error: expected `:` at line 1 column 7

hyperjson/tests/test_ujson.py:820: JSONDecodeError
_________ UltraJSONTests.test_WriteArrayOfSymbolsFromList _________

self = <test_ujson.UltraJSONTests testMethod=test_WriteArrayOfSymbolsFromList>

    def test_WriteArrayOfSymbolsFromList(self):
        self.assertEqual("[true, false, null]",
>                        hyperjson.dumps([True, False, None]))
E       AssertionError: '[true, false, null]' != '[true,false,null]'
E       - [true, false, null]
E       ?       -      -
E       + [true,false,null]

hyperjson/tests/test_ujson.py:846: AssertionError
________ UltraJSONTests.test_WriteArrayOfSymbolsFromTuple _________

self = <test_ujson.UltraJSONTests testMethod=test_WriteArrayOfSymbolsFromTuple>

    def test_WriteArrayOfSymbolsFromTuple(self):
        self.assertEqual("[true, false, null]",
>                        hyperjson.dumps((True, False, None)))
E       AssertionError: '[true, false, null]' != '[true,false,null]'
E       - [true, false, null]
E       ?       -      -
E       + [true,false,null]

hyperjson/tests/test_ujson.py:850: AssertionError
___________ UltraJSONTests.test_decodeArrayDepthTooBig ____________

self = <test_ujson.UltraJSONTests testMethod=test_decodeArrayDepthTooBig>

    def test_decodeArrayDepthTooBig(self):
        input = '[' * (1024 * 1024)
>       self.assertRaises(RecursionError, hyperjson.loads, input)
E       _hyperjson.JSONDecodeError: Value: "[{{", Error: key must be a string at line 1 column 2

hyperjson/tests/test_ujson.py:397: JSONDecodeError
_______________________________ UltraJSONTests.test_decodeTrueBroken ________________________________

self = <test_ujson.UltraJSONTests testMethod=test_decodeTrueBroken>

    def test_decodeTrueBroken(self):
        input = "tru"
>       self.assertRaises(ValueError, hyperjson.loads, input)
E       _hyperjson.JSONDecodeError: Value: "tru", Error: expected ident at line 1 column 3

hyperjson/tests/test_ujson.py:413: JSONDecodeError
_______________________ UltraJSONTests.test_decodeWithTrailingNonWhitespaces ________________________

self = <test_ujson.UltraJSONTests testMethod=test_decodeWithTrailingNonWhitespaces>

    def test_decodeWithTrailingNonWhitespaces(self):
        input = "{}\n\t a"
>       self.assertRaises(JSONDecodeError, hyperjson.loads, input)
E       _hyperjson.JSONDecodeError: Value: "{}\n\t a", Error: trailing characters at line 2 column 3

hyperjson/tests/test_ujson.py:790: JSONDecodeError
__________________________________ UltraJSONTests.test_dumpToFile ___________________________________

self = <test_ujson.UltraJSONTests testMethod=test_dumpToFile>

    def test_dumpToFile(self):
        f = six.StringIO()
        hyperjson.dump([1, 2, 3], f)
>       self.assertEqual("[1, 2, 3]", f.getvalue())
E       AssertionError: '[1, 2, 3]' != '[1,2,3]'
E       - [1, 2, 3]
E       ?    -  -
E       + [1,2,3]

hyperjson/tests/test_ujson.py:556: AssertionError
_____________________________ UltraJSONTests.test_dumpToFileLikeObject ______________________________

self = <test_ujson.UltraJSONTests testMethod=test_dumpToFileLikeObject>

    def test_dumpToFileLikeObject(self):
        class filelike:
            def __init__(self):
                self.bytes = ''

            def write(self, bytes):
                self.bytes += bytes

        f = filelike()
        hyperjson.dump([1, 2, 3], f)
>       self.assertEqual("[1, 2, 3]", f.bytes)
E       AssertionError: '[1, 2, 3]' != '[1,2,3]'
E       - [1, 2, 3]
E       ?    -  -
E       + [1,2,3]

hyperjson/tests/test_ujson.py:568: AssertionError
_______________________ UltraJSONTests.test_encodeListLongUnsignedConversion ________________________

self = <test_ujson.UltraJSONTests testMethod=test_encodeListLongUnsignedConversion>

    def test_encodeListLongUnsignedConversion(self):
        input = [18446744073709551615,
                 18446744073709551615, 18446744073709551615]
        output = hyperjson.dumps(input)

>       self.assertEqual(input, hyperjson.loads(output))
E       AssertionError: Lists differ: [18446744073709551615, 18446744073709551615, 18446744073709551615] != [1.8446744073709552e+19, 1.8446744073709552e+19, 1.8446744073709552e+19]
E
E       First differing element 0:
E       18446744073709551615
E       1.8446744073709552e+19
E
E       - [18446744073709551615, 18446744073709551615, 18446744073709551615]
E       ?                   ^ ^^^^                ^ ^^^^                ^^^
E
E       + [1.8446744073709552e+19, 1.8446744073709552e+19, 1.8446744073709552e+19]
E       ?   +               +++ ^^^ ^               +++ ^^^ ^               +++ ^

hyperjson/tests/test_ujson.py:495: AssertionError
_________________________ UltraJSONTests.test_encodeLongUnsignedConversion __________________________

self = <test_ujson.UltraJSONTests testMethod=test_encodeLongUnsignedConversion>

    def test_encodeLongUnsignedConversion(self):
        input = 18446744073709551615
        output = hyperjson.dumps(input)

>       self.assertEqual(input, hyperjson.loads(output))
E       AssertionError: 18446744073709551615 != 1.8446744073709552e+19

hyperjson/tests/test_ujson.py:509: AssertionError
_______________________________ UltraJSONTests.test_encodeOrderedDict _______________________________

self = <test_ujson.UltraJSONTests testMethod=test_encodeOrderedDict>

    @unittest.skipIf(sys.version_info < (2, 7), "No Ordered dict in < 2.7")
    def test_encodeOrderedDict(self):
        from collections import OrderedDict
        input = OrderedDict([(1, 1), (0, 0), (8, 8), (2, 2)])
        self.assertEqual('{"1": 1, "0": 0, "8": 8, "2": 2}',
>                        hyperjson.dumps(input))
E       AssertionError: '{"1": 1, "0": 0, "8": 8, "2": 2}' != '{"0":0,"1":1,"2":2,"8":8}'
E       - {"1": 1, "0": 0, "8": 8, "2": 2}
E       + {"0":0,"1":1,"2":2,"8":8}

hyperjson/tests/test_ujson.py:369: AssertionError
___________________________________ UltraJSONTests.test_sortKeys ____________________________________

self = <test_ujson.UltraJSONTests testMethod=test_sortKeys>

    def test_sortKeys(self):
        data = {"a": 1, "c": 1, "b": 1, "e": 1, "f": 1, "d": 1}
        sortedKeys = hyperjson.dumps(data, sort_keys=True)
        self.assertEqual(
>           sortedKeys, '{"a": 1, "b": 1, "c": 1, "d": 1, "e": 1, "f": 1}')
E       AssertionError: '{"a":1,"b":1,"c":1,"d":1,"e":1,"f":1}' != '{"a": 1, "b": 1, "c": 1, "d": 1, "e": 1, "f": 1}'
E       - {"a":1,"b":1,"c":1,"d":1,"e":1,"f":1}
E       + {"a": 1, "b": 1, "c": 1, "d": 1, "e": 1, "f": 1}
E       ?      +  +    +  +    +  +    +  +    +  +    +

hyperjson/tests/test_ujson.py:865: AssertionError
========================= 30 failed, 102 passed, 28 skipped in 9.44 seconds =========================

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
mrecommented, Jun 19, 2018

Thanks to the help of the awesome @althonos in https://github.com/PyO3/pyo3/issues/185, I managed to finally add bytes support. With that, we now have 130 successful and 31 skipped tests and the build is passing for the first time. Needless to say, this makes me very happy. 😆 🎉 Closing this.

0reactions
mrecommented, Jun 7, 2018

With https://github.com/mre/hyperjson/commit/7a734556246c608b0faa7ac5201637542a51d84d I decided to ignore the unicode encoding test failure. UTF-8 encoding/decoding works interchangeably with json and hyperjson, the only thing that does not work (and does not make much sense imho) is to check the string lengths. Therefore I commented that part and just kept the rest.

One more test to go!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix Flaky Tests - Semaphore CI
Randomly failing tests are the hardest to debug. Here's a framework you can use to fix them and keep your test suite healthy....
Read more >
Fix remaining unit tests by kylepjohnson · Pull Request #1012
Fix remaining unit tests #1012. Merged. kylepjohnson merged 12 commits into cltk:dev from ... fix remaining akk import ... try to fix tag...
Read more >
Should failing unit tests that we're not going to fix be removed?
That being said: removing tests just because you want to see them all pass is not the answer. The preferred solution is obviously...
Read more >
3 tips for more maintainable unit tests - Devon Burriss' Blog
3 tips for more maintainable unit tests. Avoid having to fix dozens of tests every time you make a significant code change.
Read more >
Unit Tests, How to Write Testable Code, and Why It Matters
With a good unit test, we can fix a bug without actually debugging the code! Reliable. Unit tests should fail only if there's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found