Skip to main content

A package for categorizing test results.

Project description

testcato

A Python package for categorizing test results (passed, failed, skipped) and enabling AI-assisted debugging of test failures.

Project Structure

  • testcato/ - main package directory
    • categorizer.py - core logic for categorizing test results
    • llm_provider.py - module to add support for different large language models (LLMs)
  • tests/ - unit tests for the package
  • setup.py - package setup configuration
  • requirements.txt - dependencies
  • LICENSE - license file

Quick Start

from testcato.categorizer import TestCategorizer

categorizer = TestCategorizer()
test_results = [    {'name': 'test_one', 'status': 'passed'},
    {'name': 'test_two', 'status': 'failed'}
]
categories = categorizer.categorize(test_results)
print(categories)

Test Results Output

When running pytest with the --testcato option, a folder named testcato_result will be automatically created in your working directory (if it does not exist). This folder contains JSONL files with detailed tracebacks for failed tests. Each JSONL file is named with a timestamp, e.g., test_run_YYYYMMDD_HHMMSS.jsonl.

Configuration File

The testcato_config.yaml file specifies AI agents and their details. It is automatically created in your working directory when you import or install the package, if not already present.

Current AI Support

Only GPT (OpenAI) models are supported for automated test result debugging. You must configure your GPT agent in the config file (see example below). The default agent should be set to your GPT agent (e.g., default: gpt).

Planned Future Support

Support for other AI models and providers (such as Azure, Anthropic, etc.) will be added in future releases. You can prepare additional agent sections in your config for future use.

# default: gpt
#
# gpt:
#   type: openai
#   model: gpt-4
#   api_key: YOUR_OPENAI_API_KEY
#   api_url: https://api.openai.com/v1/chat/completions

Security Tip:

Avoid committing API keys to version control. Use environment variables or secret managers where possible.

Adding Support for New LLMs

This project supports integration with various large language models (LLMs) through the llm_provider.py module. To add support for a new LLM provider, follow these steps:

Implement the LLM Provider Interface

In the llm_provider.py file, create a new class or function that implements the interface expected by the package. This typically involves:

Defining how to authenticate with the LLM API (e.g., API keys, tokens). Implementing methods to send prompts or requests to the LLM. Handling responses and errors according to the package conventions. Register the New Provider

If the package uses a registry or factory pattern for LLM providers, add your new provider to the registry so it can be selected dynamically based on configuration or parameters.

Configure the Package

Update your configuration (e.g., YAML or environment variables) to specify the new LLM provider and any necessary credentials or settings.

Test the Integration

Write tests or run existing test suites to verify that the new provider works as expected within the package.

Example

class MyNewLLMProvider:
    def __init__(self, api_key):
        self.api_key = api_key

    def send_prompt(self, prompt):
        # Implement API call to the new LLM here
        response = ...  # call API with prompt and api_key
        return response.get("text", "")

After implementing, configure your package to use MyNewLLMProvider by updating the relevant settings.

Running Tests

Unit tests are located in the tests/ directory. To run tests, it is recommended to use pytest:

`pytest Make sure to install development dependencies from requirements.txt before running tests.

Troubleshooting & Notes

If testcato_config.yaml is missing or malformed, debugging features will be disabled. Please ensure the config file exists and is correctly formatted.

When running pytest, use the --testcato option to enable testcato features:

`pytest --

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

testcato-1.2.4.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

testcato-1.2.4-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file testcato-1.2.4.tar.gz.

File metadata

  • Download URL: testcato-1.2.4.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.13

File hashes

Hashes for testcato-1.2.4.tar.gz
Algorithm Hash digest
SHA256 5763a49b01bae3dc76ba9096c44117e0b3b65266af45de7d05e4f8b11a050559
MD5 e21d1a68c152afe9a7f07ba7a82ad399
BLAKE2b-256 f42dd59df6650d7713c9ac848abe4e9ba01969f7a62a7885756b12997bd654e0

See more details on using hashes here.

File details

Details for the file testcato-1.2.4-py3-none-any.whl.

File metadata

  • Download URL: testcato-1.2.4-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.13

File hashes

Hashes for testcato-1.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b9fa2d01d214dd62bfd66040933e3440374b4978e6a00845963e2e6f34b67426
MD5 823088765954ff714491fa31331fd0ac
BLAKE2b-256 bc44d0f506d1855a7f73dd6d2b7efb609fc3ea5fd14639d54d38589a9ce527f7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page