Skip to main content

A more readable text output for Python's built in unittest framework

Project description

Better PyUnit Format

A more readable text output for Python's built in unittest framework

Overview

This package simply is an implementation of the unittest.TestResult class that sits on top of the unittest.TextTestRunner test runner. It is designed to provide a more understandable output to students that are just getting started with Python. It also has pretty colors.

Using Better PyUnit Format

  1. Install the package via pip with pip install Better-PyUnit-Format
  2. Replace the test result in your TextTestRunner with BetterPyUnitFormat
  3. Run your testsuite!

Example code

import unittest

from BetterPyUnitFormat.BetterPyUnitFormat import BetterPyunitFormatResult
import test

if __name__ == "__main__":
    testSuite = unittest.loader.makeSuite(test.Test)
    runner = unittest.TextTestRunner(resultclass=BetterPyunitFormatResult)
    runner.run(testSuite)

Example Execution

# test.py

import unittest


class Test(unittest.TestCase):
    def test_failure(self):
        """This test should fail"""
        self.assertEquals(1, 2)

    def test_success(self):
        """This test should pass"""
        self.assertEquals(1, 1)

    def test_error(self):
        """This test will error"""
        0/0

    @unittest.skip("Skipping this test :)")
    def test_skip(self):
        """This test will be skipped"""
        self.assertEquals(1, 2)
====================
--------------------
[ RUN      ] This test will error (test.Test.test_error)
[    ERROR ] This test will error
A(n) ZeroDivisionError occurred:
[ZeroDivisionError] division by zero

-------------------- 

--------------------
[ RUN      ] This test should fail (test.Test.test_failure)
[     FAIL ] This test should fail
Failure reason:
1 != 2

-------------------- 

--------------------
[ RUN      ] This test will be skipped (test.Test.test_skip)
[     SKIP ] This test will be skipped
Skip Reason: Skipping this test :)
-------------------- 

--------------------
[ RUN      ] This test should pass (test.Test.test_success)
[       OK ] This test should pass
-------------------- 

====================
[  FAILED  ] 
1 tests passed.
1 tests failed.
1 tests errored.
1 tests skipped.
1 / 4
====================
Ran 4 tests in 0.001s

FAILED (failures=1, errors=1, skipped=1)

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

Better-PyUnit-Format-0.1.1.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

Better_PyUnit_Format-0.1.1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file Better-PyUnit-Format-0.1.1.tar.gz.

File metadata

  • Download URL: Better-PyUnit-Format-0.1.1.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for Better-PyUnit-Format-0.1.1.tar.gz
Algorithm Hash digest
SHA256 31feba35947f58c2a2f20997d3a4eee3ed250f7eaff588f6560df28ab219ea7b
MD5 124bd7abbb051ad97495bb836c87e9b7
BLAKE2b-256 d6f1df8daac40686d6276cd4bcdf4d094824bf82f1f2f05189e143eb9646d853

See more details on using hashes here.

File details

Details for the file Better_PyUnit_Format-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for Better_PyUnit_Format-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 49942f730aa042423789ad172808059107513f8a7aef246b2d0a3f20d4976d31
MD5 babdb3af6f3e8451550c1682b6654208
BLAKE2b-256 23f7b9be24f7eed57821810856cfdebf6ad2bc8ca45ed3e21653fcf50fd10341

See more details on using hashes here.

Supported by

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