Composable "regular expressions" for data structures.
This module allows easy and flexible deep comparisons of
datastructure. It's not well documented yet but it's a port to python
of Test::Deep which is well documented
(http://search.cpan.org/~fdaly/Test-Deep/).
It can provide useful output, pin-pointing where 2 items begin to
differ, rather than just returning true or false. This makes it very
useful for unit-testing and deep.test provides classes for use with
unittest.py .
It allows easy comparison of objects - it just checks that
they're in the same class and have the same __dict__.
It allows set-wise comparison of lists or tuples.
Most importantly it allows aribitrary nesting of the various
comparisons and embedding of them inside other datastructures and
object. This makes it easy to perform comparisons that would otherwise
have been tedious.
It turns what would have involved lots of looping and iffing and
comparing into just putting together a structure that looks like what
you're trying to match.
Examples:
###
# Test that we have a list of objects from the correct classes (yes you
# can do this easily without deep.py).
three_types = [deep.InstanceOf(int),
deep.InstanceOf(list),
deep.InstanceOf(dict)]
diff = deep.diff([1, 2, 3], three_types)
if diff:
diff.print_full()
# Outputs
x[1]:
Expected: instance of <type 'list'>
Actual : instance of <type 'int'>
###
# Test that we have a list of strings that all match a pattern.
list_of_bings = deep.Elements(deep.Re("^bing "))
diff = deep.diff(["bing bong", "bing crosby", "bin laden"], list_of_bings)
if diff:
diff.print_full()
# Outputs
x[2]:
Expected: something matching '^bing '
Actual : 'bin laden'
###
# Test that we have an object who's "wibble" attribute is a dict and
# that this dict has 3 keys "time", "bings" and "things" and
# "time". We want to make sure that "time" is a float and we want to
# reuse the comparisons from the earlier examples for the other 2
# keys.
complex = deep.Attr("wibble", {"time": deep.InstanceOf(float),
"bings": list_of_bings,
"things": three_types})
class O(object):
wibble = {"time": 1234.12,
"bings": ["bing go"],
"things": [1, [], {}, "hello"]}
diff = deep.diff(O(), complex)
if diff:
diff.print_full()
# Outputs
len(x.wibble['things']):
Expected: 3
Actual : 4
Metadata
Release files for deep 0.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| deep-0.10.tar.gz | 18.6 kB | Without provenance | Details |
Release files / deep-0.10.tar.gz
| Download URL | deep-0.10.tar.gz |
|---|---|
| Size | 18.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fd692023d65b21c11bdaa38f7b5264d195d2ed678ffc82f841a4a320a8e0127b
|
|
BLAKE2b-256 checksum How to use checksums |
440dae234be6c9595329de866a17bfb85b41d4761e6252bda9e227559f6f51a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for deep 0.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.