ditto.exceptions¶
pytest-ditto's own exceptions subclass DittoException. Some misuse raises a
standard TypeError or ValueError instead, and errors from recorders and
backends propagate unchanged. Advisory warnings use the DittoWarning category.
DittoWarning
¶
Bases: UserWarning
Category for all pytest-ditto advisory warnings.
Subclasses UserWarning, so a blanket ignore::UserWarning still applies;
use ignore::ditto.exceptions.DittoWarning to silence only ditto's
advisories, or error::ditto.exceptions.DittoWarning to escalate them.
DittoException
¶
Bases: Exception
Base class for pytest-ditto's own exceptions.
Not every error ditto raises is one: misuse such as a snapshot key that
isn't a str raises TypeError, and a target ditto can't resolve raises
ValueError. Errors from a recorder or a backend, such as a value the
recorder can't serialise or a storage failure, propagate unchanged.
AdditionalMarkError()
¶
Bases: DittoException
Raised when a test has more than one record mark.
Marks on the test's function, class and module all count, so a function mark doesn't override a class or module mark: use one or the other.
Source code in ditto/exceptions.py
DittoMarkHasNoIOType()
¶
Bases: DittoException
Raised when a record mark doesn't name a recorder.
The recorder name is the mark's first argument, and is required even when
the mark only sets a target: write @ditto.json(target=...) rather than
@ditto.record(target=...).
Source code in ditto/exceptions.py
DittoUnknownRecorderError(name, available)
¶
Bases: DittoException
Raised when a requested recorder is not installed.
Source code in ditto/exceptions.py
DittoRecorderLoadError(name, distribution, cause, hint='')
¶
Bases: DittoException
Raised when an installed recorder's entry point fails to load.
Source code in ditto/exceptions.py
DittoRecorderConflictError
¶
Bases: DittoException
Raised when a recorder registration breaks the plugin contract.
Raised when a conflicted recorder is looked up, and when register is
given a name that would conflict. The message describes the conflict and
names the distributions involved.
DittoBackendLoadError(scheme, distribution, cause)
¶
Bases: DittoException
Raised when an installed backend's entry point fails to load.
Source code in ditto/exceptions.py
DittoBackendConflictError
¶
Bases: DittoException
Raised when a backend registration breaks the plugin contract.
Raised when a conflicted scheme is looked up. The message describes the conflict and names the distributions involved.
DittoBackendChangedError(scheme, uri)
¶
Bases: DittoException
Raised when a target's backend would change partway through a session.
ditto treats a target URI as one store in the lock, verify and prune,
so every backend for a target in a session must come from the same factory.
Source code in ditto/exceptions.py
DittoJSONSerializationError(path, detail)
¶
Bases: DittoException
Raised for values outside ditto's strict JSON data model.
Source code in ditto/exceptions.py
DuplicateSnapshotKeyError(key)
¶
Bases: DittoException
Raised when a test calls snapshot() twice with the same key.
Source code in ditto/exceptions.py
DittoSnapshotNameCollisionError(storage_key, first, second)
¶
Bases: DittoException
Raised when two different snapshots would be stored under one name.
A stored name ends in a short hash of the snapshot's identity, so this needs two snapshots whose readable labels and hashes both match.
Source code in ditto/exceptions.py
DittoSnapshotNameTooLongError(module, limit)
¶
Bases: DittoException
Raised when a test module's path leaves no room for a snapshot's name.
A file:// snapshot's name starts with the module path, dotted, and must
fit in the file system's limit for a file name.
Source code in ditto/exceptions.py
DittoAmbiguousTargetError(context)
¶
Bases: DittoException
Raised when a test's target is set in two conflicting ways.
A mark can't set both target= and target_profile=, and the
ditto_target and ditto_target_profile ini options can't both be set.
Source code in ditto/exceptions.py
DittoUnknownProfileError(name, available)
¶
Bases: DittoException
Raised when a test selects a target profile that isn't defined.
The message lists the profiles that are defined.
Source code in ditto/exceptions.py
DittoInvalidProfileError(name, detail=None)
¶
Bases: DittoException
Raised when a target profile isn't a URI string or a valid table.
A table needs a string uri and may have a storage_options mapping; any
other key is an error.
Source code in ditto/exceptions.py
DittoDuplicateProfileError(names)
¶
Bases: DittoException
Raised when a profile name is defined in both places profiles come from.
Profiles come from the ditto_target_profiles fixture and the
[tool.pytest-ditto.target_profiles] table in pyproject.toml; neither
takes precedence, so a name defined in both is an error.
Source code in ditto/exceptions.py
DittoLockFileError(detail)
¶
Bases: DittoException
Raised when ditto.lock can't be read.
--ditto-verify and --ditto-prune report it and fail the run, and an
ordinary run only warns. A --ditto-lock rebuild replaces the unreadable
lock instead.
Source code in ditto/exceptions.py
DittoLockFileVersionError(expected, got)
¶
Bases: DittoLockFileError
Raised when ditto.lock has a format version this pytest-ditto can't read.
Usually a newer pytest-ditto wrote the lock; upgrade to read it.
Source code in ditto/exceptions.py
DittoUnhashableStorageOptionsError(value)
¶
Bases: DittoException
Raised when ditto_storage_options contains an unhashable value.