Skip to main content

DataDiff is a library to provide human-readable diffs of python data structures. It can handle sequence types (lists, tuples, etc), sets, and dictionaries.

Dictionaries and sequences will be diffed recursively, when applicable.

It has special-case handling for multi-line strings, showing them as a typical unified diff.

Drop-in replacements for some nose assertions are available. If the assertion fails, a nice data diff is shown, letting you easily pinpoint the root difference.

datadiff works on Python 2.6 through Python 3.

DataDiff project homepage: http://sourceforge.net/projects/datadiff/

Example

Here’s an example:

>>> from datadiff import diff
>>> a = dict(foo=1, bar=2, baz=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
>>> b = dict(foo=1, bar=4, baz=[0, 1, 2, 3, 4, 5, 6, 7, 8])
>>> print diff(a, b)
--- a
+++ b
{
-'bar': 2,
+'bar': 4,
 'baz': [
 @@ -5,11 +5,8 @@
  6,
  7,
  8,
 -9,
 -10,
 -11,
 ],
 'foo': 1,
}
>>>
>>> from datadiff.tools import assert_equal
>>> assert_equal([1, 2, 3], [1, 2, 5])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "datadiff/tools.py", line 29, in assert_equal
    raise AssertionError(msg)
AssertionError:
--- a
+++ b
[
@@ -0,2 +0,2 @@
 1,
 2,
-3,
+5,
]

License

Copyright Dave Brondsema

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Release files for datadiff 2.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for datadiff 2.2.0
File Size Uploaded
datadiff-2.2.0.tar.gz 13.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for datadiff 2.2.0
File Interpreter ABI Platform
datadiff-2.2.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 27.5 kB

Release files / datadiff-2.2.0.tar.gz

Download URL datadiff-2.2.0.tar.gz
Size 13.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7ce70dfeea8c33f1d88db46b0effee905cc36b4db739f6bb070a82de8981d30b
BLAKE2b-256 checksum
How to use checksums
59cdc1db34803f8093ad9d3621b0bf778a12bbd8c11f540a5fbd14f325f0f6b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Release files / datadiff-2.2.0-py2.py3-none-any.whl

Download URL datadiff-2.2.0-py2.py3-none-any.whl
Size 14.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
4e63e4abe3955a77c631eaf94aa86836040ea1648d8a06c600b5e75c48d486c6
BLAKE2b-256 checksum
How to use checksums
df83479aca48c269f6224db0c34e389a437d480ffe4ed48b909347ec301cc61a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Release history Release notifications | RSS feed

This release

2.2.0 This release

2 release files

2.1.0

2 release files

2.0.0

1 release file

1.1.6

1 release file

1.1.5

1 release file

1.1.4

1 release file

1.1.3

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page