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.3.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.3-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: eazytester-26.5.3.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.3.tar.gz
Algorithm Hash digest
SHA256 f621fcd4c6b41a624e451b933b5d1d6411aee7ac62647a351b3ed61c6d0f120c
MD5 7eb8008496fafb63e44e28141d6287f0
BLAKE2b-256 e704b869f8534275d13bf4ed3d19d065501f7734cedba7165dad75ada8253ae9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: eazytester-26.5.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 18c3024a6df0f656f32a6c286727c0ff87ee90432300ace55ca835ef65483319
MD5 d82acc7711bfdeffac5d73f29e79d393
BLAKE2b-256 e646eb381afd0385cd3df3120fa0ffc3f4beea0fcc7840ba42e8e85c9b7a7307

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