Skip to main content
# PyUnitReport

banrieen_PyUnitReport modified from PyUnitReport is a unittest test runner that save test results in Html files, for human readable presentation of results.

## Installation

```bash
$ pip install banrieen_PyUnitReport
```

## Usage

### testcase

```python
from pyunitreport import HTMLTestRunner
import unittest

class TestStringMethods(unittest.TestCase):
""" Example test for HtmlRunner. """

def test_upper(self):
self.assertEqual('foo'.upper(), 'FOO')

def test_isupper(self):
self.assertTrue('FOO'.isupper())
self.assertFalse('Foo'.isupper())

def test_split(self):
s = 'hello world'
self.assertEqual(s.split(), ['hello', 'world'])
# check that s.split fails when the separator is not a string
with self.assertRaises(TypeError):
s.split(2)

def test_error(self):
""" This test should be marked as error one. """
raise ValueError

def test_fail(self):
""" This test should fail. """
self.assertEqual(1, 2)

@unittest.skip("This is a skipped test.")
def test_skip(self):
""" This test should be skipped. """
pass

if __name__ == '__main__':
unittest.main(testRunner=HTMLTestRunner(output='example_dir'))
```

In most cases, you can use `PyUnitReport` with `unittest.main`, just pass it with the `testRunner` keyword.

For `HTMLTestRunner`, the only parameter you must pass in is `output`, which specifies the directory of your generated report. Also, if you want to specify the report name, you can use the `report_name` parameter, otherwise the report name will be the datetime you run test. And if you want to run testcases in `failfast` mode, you can pass in a `failfast` parameter and assign it to be True.

Here is another way to run the testcases.

```python
from pyunitreport import HTMLTestRunner

kwargs = {
"output": output_folder_name,
"report_name": report_name,
"failfast": True
}
result = HTMLTestRunner(**kwargs).run(task_suite)
```

### testsuite

For those who have `test suites` it works too, just create a runner instance and call the run method with your suite.

Here is an example:

```python
from unittest import TestLoader, TestSuite
from pyunitreport import HTMLTestRunner
import ExampleTest
import Example2Test

example_tests = TestLoader().loadTestsFromTestCase(ExampleTests)
example2_tests = TestLoader().loadTestsFromTestCase(Example2Test)

suite = TestSuite([example_tests, example2_tests])
kwargs = {
"output": output_folder_name,
"report_name": report_name,
"failfast": True
}
runner = HTMLTestRunner(**kwargs)
runner.run(suite)
```

## Output

### Console output

This is an example of what you got in the console.

```text
$ python examples/testcase.py

Running tests...
----------------------------------------------------------------------
This test should be marked as error one. ... ERROR (0.000575)s
This test should fail. ... FAIL (0.000564)s
test_isupper (__main__.TestStringMethods) ... OK (0.000149)s
This test should be skipped. ... SKIP (0.000067)s
test_split (__main__.TestStringMethods) ... OK (0.000167)s
test_upper (__main__.TestStringMethods) ... OK (0.000134)s

======================================================================
ERROR [0.000575s]: This test should be marked as error one.
----------------------------------------------------------------------
Traceback (most recent call last):
File "examples/testcase.py", line 23, in test_error
raise ValueError
ValueError

======================================================================
FAIL [0.000564s]: This test should fail.
----------------------------------------------------------------------
Traceback (most recent call last):
File "examples/testcase.py", line 27, in test_fail
self.assertEqual(1, 2)
AssertionError: 1 != 2

----------------------------------------------------------------------
Ran 6 tests in 0.002s

FAILED
(Failures=1, Errors=1, Skipped=1)

Generating HTML reports...
Template is not specified, load default template instead.
Reports generated: /Users/Leo/MyProjects/ApiTestEngine/src/pyunitreport/reports/example_dir/2017-07-26-23-33-49.html
```

### Html Output

![html output](resources/html_output.gif)

![html output](resources/html_output.png)


Metadata

Release files for banrieen-PyUnitReport 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for banrieen-PyUnitReport 0.1.4
File Size Uploaded Provenance Actions
banrieen_PyUnitReport-0.1.4.tar.gz 11.2 kB Without provenance Details for banrieen_PyUnitReport-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for banrieen-PyUnitReport 0.1.4
File Interpreter ABI Platform Actions
banrieen_PyUnitReport-0.1.4-py3-none-any.whl Python 3 none any Details for banrieen_PyUnitReport-0.1.4-py3-none-any.whl

Total release size: 24.4 kB

Release files / banrieen_PyUnitReport-0.1.4.tar.gz

Download URL banrieen_PyUnitReport-0.1.4.tar.gz
Size 11.2 kB
Tags Source
SHA-256 checksum
How to use checksums
bda7494ac2d25a0f5b0f11087f16dcf82f9c104a8de314f1712202c917e05aa2
BLAKE2b-256 checksum
How to use checksums
500a33534ef14aa95458512cd0906c2a9b22f470c58cce4e7e01db866b206c2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / banrieen_PyUnitReport-0.1.4-py3-none-any.whl

Download URL banrieen_PyUnitReport-0.1.4-py3-none-any.whl
Size 13.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
59a4b0823d79fcd1949770352873255c72def95a6f584038f36b3110bb4c7ffe
BLAKE2b-256 checksum
How to use checksums
1dae002494878496f18feca009f88f3f370c61042d1bf81458eee028e43f20a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for banrieen-PyUnitReport 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page