Skip to main content

Testionary

Python 3.10+ License: MIT

A library providing tools to inspect dicionaries during testing.

Installation

Using pip:

pip install testionary

or using uv for project management:

uv add testionary

Usage

Read and Modified attributes

Accessing a value using e.g. the []-operator or dict.get() method will cause the key to be added to TrackingDict.accessed_keys. Setting a value e.g. using assignment together with the []-operator will get tracked using TrackingDict.modified_keys. Here is a small example:

# My library code:
>>> def set_danger(enemy):
...     if enemy["type"] == "Rabbit":
...         enemy["danger"] = 9000


# My test:
>>> from testionary.tracking_dict import TrackingDict
>>> tracked_dict = TrackingDict({"type": "Rabbit", "danger": 42})
>>> set_danger(tracked_dict)
>>> "type" in tracked_dict.accessed_keys
True
>>> "danger" in tracked_dict.modified_keys
True

Tracked Access methods

  • []
  • .get

Tracked Modification methods

  • [] =
  • .update()
  • |=

Iteration

When iterating over dictionary, e.g. when using dictionary comprehension, you might be accessing a few or all of the items. However, in these scenarios it is common to actually interate over all the key-value pairs while filtering on some condition. Instead of attemting to track each access with TrackingDict.accessed_keys, a boolean attribute, TrackingDict.has_been_iterated, is used instead. Here is an example of this being used:

# Libray code
>>> def vals_as_str(_dict):
...    return {k: str(v) for k,v in _dict.items()}

# My test:
>>> from testionary.tracking_dict import TrackingDict

>>> tracked_dict = TrackingDict({"type": "Rabbit", "danger": 42, "hp": 100, "armor": 100})
>>> vals_as_str(tracked_dict)
{'type': 'Rabbit', 'danger': '42', 'hp': '100', 'armor': '100'}
>>> tracked_dict.has_been_iterated
True

Tracked Iteration Methods

  • __iter__() called by iter() and for
  • __contains__(), called by in operator in e.g. if "key" in my_dict
  • .keys()
  • .values()
  • .items()

For .keys(), .values(), and .items(), iteration is assumed following calls to these methods. The returned dict-views are not inspected.

Metadata

Release files for testionary 0.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 testionary 0.2.0
File Size Uploaded Provenance
testionary-0.2.0.tar.gz 2.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for testionary 0.2.0
File Interpreter ABI Platform
testionary-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 6.1 kB

Release files / testionary-0.2.0.tar.gz

Download URL testionary-0.2.0.tar.gz
Size 2.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f8575565ed69eff6e2590cbdda31e736f99261859712ac592fd24375c26c5356
BLAKE2b-256 checksum
How to use checksums
e723cdd65e2aa4c0b1eeab250a8d915913054f913c0b5fd3a5b653dec18980bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.19

Release files / testionary-0.2.0-py3-none-any.whl

Download URL testionary-0.2.0-py3-none-any.whl
Size 3.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
deb7db711fba6fd879edae780aa6cc5e29bb2f71901fe5f3534d568009c957ef
BLAKE2b-256 checksum
How to use checksums
211f4f14f85183235099d792114b250980ef1fec60dc4dd2ee7c302d373d3e58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.19

Security for testionary 0.2.0

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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

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