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

Edge case with pretty_print and short_empty_elements #352

Open
bpandola opened this issue Jul 18, 2024 · 0 comments
Open

Edge case with pretty_print and short_empty_elements #352

bpandola opened this issue Jul 18, 2024 · 0 comments

Comments

@bpandola
Copy link

I expected that stripping out the "pretty" characters would be identical to the "non-pretty" result:

def test_pretty_print_and_short_empty_elements_with_empty_array():
    input_dict = {"Foos": {"Foo": []}}
    compact = unparse(
        input_dict, pretty=False, short_empty_elements=True, full_document=False
    )
    pretty = unparse(
        input_dict, pretty=True, short_empty_elements=True, full_document=False
    )
    pretty_compacted = pretty.replace("\n", "").replace("\t", "")
    assert pretty_compacted == compact

But they are different:

>       assert pretty_compacted == compact
E       AssertionError: assert '<Foos></Foos>' == '<Foos/>'
E         
E         - <Foos/>
E         + <Foos></Foos>

I realize this is a pretty (no pun intended) minor issue, but am I incorrect in thinking these two unparsings should be equivalent?

If you'd consider a PR to address this, I could take a crack at it.

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

1 participant