animedex.diag.selftest

In-process self-diagnostic for the animedex CLI.

The run_selftest() routine prints a structured environment and package report, exercises every public module’s importability, and invokes each registered Click subcommand’s --help page. It is designed to terminate cleanly under all conditions, even when a check itself throws an unexpected exception, so that:

  • a stripped binary built with PyInstaller can be smoke-tested in a clean environment without a Python interpreter installed (see .github/workflows/release_test.yml);

  • an LLM agent invoking animedex selftest always gets a parseable status block back, regardless of why something failed.

Output format

The selftest prints a banner, four sections, and a summary line. Each check produces a one-line [OK] / [FAIL] record so the report can be grepped from CI logs without parsing tracebacks; failure detail follows the failing record on subsequent indented lines.

Exit codes

  • 0 - every check passed.

  • 1 - one or more checks failed; the report still printed cleanly.

  • 2 - the runner itself crashed before completing (should be unreachable in practice; defensive).

CHECK_OK

animedex.diag.selftest.CHECK_OK = '[OK]'

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

CHECK_FAIL

animedex.diag.selftest.CHECK_FAIL = '[FAIL]'

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

SECTION_RULE

animedex.diag.selftest.SECTION_RULE = '============================================================'

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

SUBSECTION_RULE

animedex.diag.selftest.SUBSECTION_RULE = '------------------------------------------------------------'

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

run_selftest

animedex.diag.selftest.run_selftest(stream: TextIOBase = None) int[source]

Execute the full self-diagnostic and return an exit code.

Parameters:

stream (io.TextIOBase, optional) – Optional destination text stream; defaults to sys.stdout. The stream is not closed by this function.

Returns:

0 if every check passed, 1 if any failed, 2 if the runner itself crashed before completing.

Return type:

int

main

animedex.diag.selftest.main() int[source]

Console-script style entry point for python -m animedex.diag.selftest.

Returns:

Process exit code (see run_selftest()).

Return type:

int