Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON #15

Closed
CScharer opened this issue May 20, 2022 · 3 comments
Closed

JSON #15

CScharer opened this issue May 20, 2022 · 3 comments

Comments

@CScharer
Copy link

This is not an issue, but rather a question/request. Why not have it write out a json file with a list of the json rather than a log file with bunch of lines of dictionaries?

@nicoddemus
Copy link
Member

Hi @CScharer,

As stated in the README:

Each line of the report log contains a self contained JSON object corresponding to a testing event, such as a collection or a test result report. The file is guaranteed to be flushed after writing each line, so systems can read and process events in real-time.

One of the use cases is being able to read the reports in real time, which would not be possible if we formatted it as a list, because the list would only be fully formed (the ending ]) at the end of the session. Having one JSON object per line allows each line to be processed as they are written.

Closing this for now, feel free to follow up with more questions.

@xsamueljr
Copy link

xsamueljr commented Jun 9, 2023

This plugin can't include an option to convert JSON Lines in JSON once the tests have finished? That would be very helpful to make documents in an automated way, for example, a summary with the results in MarkDown format. Or is it not very different to process both formats? Sorry, I don't have much experience

(I apologize for my lack of ability regarding the lexicon of the English language)

@The-Compiler
Copy link
Member

The-Compiler commented Jun 9, 2023

It's not very different indeed. All you would do is something like:

with open("pytest.jsonl") as f:
    for line in f:
        rep = json.load(line)
        # do something with the data in 'rep'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants