GithubHelp home page GithubHelp logo

Fix remaining unit tests about hyperjson HOT 10 CLOSED

mre avatar mre commented on June 6, 2024
Fix remaining unit tests

from hyperjson.

Comments (10)

mre avatar mre commented on June 6, 2024 1

Thanks to the help of the awesome @althonos in PyO3/pyo3#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.

from hyperjson.

mre avatar mre commented on June 6, 2024

See #6

from hyperjson.

mre avatar mre commented on June 6, 2024

Four tests are failing because it doesn't find JSONDecodeError. I tried to fix that, but to no avail.
Seems like I don't understand how exceptions get defined. 😅
Opened an issue here: PyO3/pyo3#171

from hyperjson.

wdv4758h avatar wdv4758h commented on June 6, 2024

Multiple test cases are failing because serde_json::to_string output a compact result, while the std json output a extra space between key and value.

from hyperjson.

mre avatar mre commented on June 6, 2024

@wdv4758h, good point.

I'm not sure whether we should treat that as a bug or an implementation detail. After all, JSON is a whitespace-agnostic format, so technically it should not make a difference. It might also cost us some performance to fix that in hyperjson and it doesn't seem like there will be an upstream change any time soon (see e.g. serde-rs/json#393).
So I suggest to keep that for a while and fix the affected unit tests by ignoring whitespace like so https://github.com/mre/hyperjson/blob/master/tests/test_dumps.py#L34. Sounds good?

from hyperjson.

mre avatar mre commented on June 6, 2024

So we are down to four failing unit tests after fixing issues with JSONDecodeError. 🎉
The remaining tests are harder to fix, I guess and have to do with serde_json's (or Rusts) internal representation of types as strings.

For example:

self = <test_ujson.UltraJSONTests testMethod=test_encodeLongUnsignedConversion>

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

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

I don't know how to fix that yet. @wdv4758h, if you have an idea I'd be more than happy to listen. 😄

from hyperjson.

mre avatar mre commented on June 6, 2024

Correction, we are down to four failing test now. Fixed the issues regarding long int parsing.
See e47ef32.

from hyperjson.

mre avatar mre commented on June 6, 2024

Whoops, broke parse_int test with the last commit.
Should be fixed now. So we're down to three failing tests now, which all have to do with utf8 handling.
Python handles utf8 as unicode code points when serializing, I guess. Don't know what to do in this case. We will see.

from hyperjson.

wdv4758h avatar wdv4758h commented on June 6, 2024

awesome progress !!! 🎆

from hyperjson.

mre avatar mre commented on June 6, 2024

With 7a73455 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!

from hyperjson.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.