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

Uploaded Python 3

File details

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

File metadata

  • Download URL: eazytester-26.5.1.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.1.tar.gz
Algorithm Hash digest
SHA256 656b152e61c7e59729f4829dec26a10537b6bff896a3cfdde1d6f33ab97414d2
MD5 d36c6cf103ef8414ace797b078dfdbed
BLAKE2b-256 469cfe9d7fdd1df0a3c34bb97e132b737dc40a6705060311bd358012557afe2e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: eazytester-26.5.1-py3-none-any.whl
  • Upload date:
  • Size: 4.8 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 13737272e04023c365ee93921833f54e9de6a4683be49d1376435b55394aca07
MD5 d323bdac640cfd51714b88a1a3dc3632
BLAKE2b-256 8431251e49f5a365b436a8da98c7da9ce4fc176a2d2354c11897f9235f82b628

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