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 BetterPyUnitFormat
  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.0.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: Better-PyUnit-Format-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 1e7a705e776b51d44a6fcbba43e4e070405d7716fbe6885ef6c91b8321b937f1
MD5 6f956319d1db3091dac83d33bdf99c08
BLAKE2b-256 e8ec8c3f7072e181a6249f2f9a275dcdd6c84b486c6006c6cd714cced9b24202

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Better_PyUnit_Format-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4743adc9e000dd3d8808e8190944a620ed96210d22aaa0afccf7cae76e9846bb
MD5 7dfa523d26db14b7de2c5827c13a8237
BLAKE2b-256 17f739783a4bef66ab63220c84bc86af93b6791d24e0dbaec30978f9adb8f3d0

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