Skip to main content

Utility for running unit tests and logging results in a structured format.

Project description

EazyTests

A robust and easy-to-use test runner for Python unittest test classes with automatic logging and reporting.

Overview

EazyTests provides a simple yet powerful Engine class that allows you to run one or more unittest test classes, capture results, and automatically log them to a file. Perfect for test automation, CI/CD pipelines, and test suite management.

Features

  • ✅ Run one or multiple test classes in a single call
  • ✅ Automatic test result logging with timestamps
  • ✅ Comprehensive test reporting (passed, failed, errors, skipped)
  • ✅ Detailed failure and error tracebacks in log files
  • ✅ Optional automatic log file opening
  • ✅ Method chaining for fluent API
  • ✅ Programmatic access to test results

Installation

pip install eazytests

Quick Start

Basic Usage

from unittest import TestCase
from eazytester import Engine

class TestReaders(TestCase):
    def test_read_txt_file(self):
        # Your test code here
        self.assertTrue(True)

    def test_read_xlsx_file(self):
        # Your test code here
        self.assertIsNotNone({})

# Run tests
engine = Engine()
success = engine.add_tests(TestReaders).run_tests()

print(f"All tests passed: {success}")

Multiple Test Classes

from eazytester import Engine

engine = Engine(output_file="results/test_report.log")
success = engine.add_tests(TestReaders, TestWriters, TestParsers).run_tests()

Without Auto-opening Log File

engine = Engine(output_file="test_results.log", open_log=False)
engine.add_tests(TestReaders).run_tests()

Accessing Results Programmatically

engine = Engine()
engine.add_tests(TestReaders).run_tests()

results = engine.get_results()
print(f"Total tests: {results['total_tests']}")
print(f"Failures: {results['failures']}")
print(f"Errors: {results['errors']}")
print(f"Success: {results['success']}")

API Reference

Engine Class

Constructor

Engine(output_file: Optional[str] = None, open_log: bool = True)

Parameters:

  • output_file (str, optional): Path to the log file. Defaults to 'test_results.log'
  • open_log (bool, optional): Whether to automatically open the log file after writing. Defaults to True

Methods

add_tests(*test_classes: Type[TestCase]) -> Engine

Add one or more test classes to run.

Parameters:

  • *test_classes: One or more unittest.TestCase subclasses

Returns: Engine instance (allows method chaining)

Raises: ValueError if a class is not a subclass of unittest.TestCase

Example:

engine.add_tests(TestClass1, TestClass2, TestClass3)
run_tests() -> bool

Execute all added test classes and log results.

Returns: True if all tests passed, False otherwise

Raises: RuntimeError if no test classes have been added

Example:

success = engine.run_tests()
get_results() -> dict

Get test results summary.

Returns: Dictionary containing:

  • total_tests (int): Total number of tests run
  • failures (int): Number of test failures
  • errors (int): Number of test errors
  • skipped (int): Number of skipped tests
  • success (bool): Whether all tests passed
  • output (str): Detailed test output
  • failures_detail (list): List of (test, traceback) tuples for failures
  • errors_detail (list): List of (test, traceback) tuples for errors

Example:

results = engine.get_results()

Log File Format

The generated log file includes:

Test Results - 2026-05-15 10:30:45
============================================================

SUMMARY
------------------------------------------------------------
Total Tests: 5
Passed: 4
Failures: 0
Errors: 1
Skipped: 0
Status: ✗ FAILED

DETAILED OUTPUT
------------------------------------------------------------
[Detailed test runner output...]

ERRORS
------------------------------------------------------------
[Error tracebacks if any...]

Examples

Example 1: Running Tests from a Single Class

from unittest import TestCase
from eazytester import Engine

class TestMathOperations(TestCase):
    def test_addition(self):
        self.assertEqual(2 + 2, 4)

    def test_subtraction(self):
        self.assertEqual(5 - 2, 3)

engine = Engine(output_file="math_tests.log")
success = engine.add_tests(TestMathOperations).run_tests()

Example 2: Running Multiple Test Suites

from eazytester import Engine

engine = Engine(output_file="full_test_suite.log")
engine.add_tests(
    TestDataParsers,
    TestFileReaders,
    TestDataValidators
).run_tests()

Example 3: Suppressing Auto-Open and Manual Result Checking

engine = Engine(output_file="results.log", open_log=False)
engine.add_tests(MyTestClass).run_tests()

results = engine.get_results()
if not results['success']:
    print(f"Tests failed! {results['failures']} failures, {results['errors']} errors")

Requirements

  • Python 3.7+
  • unittest (built-in standard library)

License

MIT

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

Support

For issues, questions, or suggestions, please open an issue on the project repository.

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

eazytester-26.5.2.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

eazytester-26.5.2-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file eazytester-26.5.2.tar.gz.

File metadata

  • Download URL: eazytester-26.5.2.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for eazytester-26.5.2.tar.gz
Algorithm Hash digest
SHA256 c918859f218b6c445e74f99f4229dd513449dee3b50597a281a6425ee893b112
MD5 ce6ee4fa7e6401a41b2a01e829acab5c
BLAKE2b-256 0ef253d3199b272ea1be79687e44266f8ca6b04ca6d92c94a7eef26836db1f69

See more details on using hashes here.

File details

Details for the file eazytester-26.5.2-py3-none-any.whl.

File metadata

  • Download URL: eazytester-26.5.2-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for eazytester-26.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8bbbf4eb58d6907adbb1595745e92519e571d70e62dd895ca27f9029069a4c97
MD5 c263f71c0cf3402254ac274faf92df5f
BLAKE2b-256 db515b4bb00f439a1724d1ad5e5307de0d1edd41cb3110a8ac727aa8fe1d2513

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