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

Pretty printer #142

Open
m-aciek opened this issue Nov 5, 2020 · 0 comments
Open

Pretty printer #142

m-aciek opened this issue Nov 5, 2020 · 0 comments

Comments

@m-aciek
Copy link

m-aciek commented Nov 5, 2020

Is your feature request related to a problem? Please describe.

I use dictdiffer in tests to show differences for assertion errors. Having a method that would pretty print a differences would make use of the library even better for me.

Describe the solution you'd like

Either

>>> dictdiffer.pretty_diff({}, {"foo": "bar"}))
add: 'foo': 'bar'
>>> dictdiffer.pretty_diff({"foo": "jar"}, {"foo": "bar"}))
change foo: 'jar' -> 'bar'
>>> dictdiffer.pretty_diff({"outer": {"foo": "jar"}}, {"outer": {"foo": "bar"}}))
change outer.foo: 'jar' -> 'bar'

or more like comparison view

>>> dictdiffer.pretty_diff({}, {"foo": "bar"}))
+ 'foo': 'bar'
>>> dictdiffer.pretty_diff({"foo": "jar"}, {"foo": "bar"}))
- 'foo': 'jar'        + 'foo': 'bar'
>>> dictdiffer.pretty_diff({"outer": {"foo": "jar"}}, {"outer": {"foo": "bar"}}))
  'outer': {            'outer': {
-   'foo': 'jar'      +   'foo': 'bar'

Additional context

https://github.com/lukaszb/pytest-dictsdiff and https://github.com/hjwp/pytest-icdiff does something similar (at least one have dictdiffer as dependency), but doesn't work for my cases.

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