This release is a pre-release and may not be stable for production use.
Repeated Test Framework
Introduction
The repeated Test Framework is designed to be used with the unittest standard library module (unittest for Python 2.7, unittest for Python 3.5), to make to generate multiple test cases against the same functionality where the difference between the test cases is different test input and differing expected results.
Features
The Framework provides the following features :
Supports Python 2 and Python 3
Easy to use
Uses a list of dictionaries (or any Iterable of mappings) to define the data for the test cases.
Requires only a single generic test function which takes the test case data and executes the test of the functionality.
Can decorate a entirely empty unittest.TestCase class - no boiler plate coded needed within the class.
Using the default settings, ensures a unique and predictable set of test method names, and useful documentation strings for each test case.
The automatically generated test methods work correctly with unittest module module default test detection, loaders, execution and reporting functionality.
Supports the use of the normal commandline usage of the unittest module, including execution of specific test cases.
Behind the scenes
Automatically generates a test method on a unittest.TestCase, one for each entry the test data list/Iterable.
By generating unique documentation strings and test names, ensures useful test result reporting from the unittest module.
By generating multiple test methods, ensures test separation so that testing continues after a test failure.
Also
Allows for customisation of the name and the documentation strings of the generated test method, using any of the data from the relevant test_case.
Provides additional decorators allowing the application of unittest test method decorators (skip, skipIf etc) to one or more of the automatically generated test cases. Can also apply your own arbitrary test method decorators to the generated test case methods.
Can combine Automatically generated test methods and explicitly provided test method on the same unittest.TestCase class.
See Using the Framework for full details of how to use the Framework, including how to customise the Framework, and how to apply decorators to the generated test methods.
See Why Use the Framework for a more detailed comparison of the Framework against other traditional ways of using the unittest module to achieve the same multiple test cases for the same functionality item with different data.
Installation
Installation is very simple :
$ pip install repeated-test-framework
To upgrade an existing installation use
$ pip install --upgrade repeated-test-framework
Getting Started
The following code snippet will illustrate the simplest use of the Framework to execute a small number of test case against the multiplication operation - a trivial example which is still illustrative of the key points.
from repeatedtestframework import GenerateTestMethods
def test_method_wrapper(index, a, b, result):
def test_method(self):
"""The actual test method which gets replicated"""
self.assertEqual( a * b, result)
return test_method_wrapper
@GenerateTestMethods(
test_name = 'test_multiplication',
test_method = test_method_wrapper,
test_input = [ {'a':1, 'b';2, 'result':2 },
{'a':2, 'b':2, 'result':4 },
{'a':3, 'b':2, 'result':6 },
{'a':3, 'b':4, 'result':11 } ] )
class TestCases(unittest.TestCase):
pass
Although the example above is trivial, it does illustrate the key features of the framework as noted.
The data to be used is provided as a list of dictionaries; the input_data attribute on the GenerateTestMethods decorator.
A test_name attribute is provided - which is a human readable string which is included verbatim into the test method name - as such it can only include alphabetic, numeric and underscore (_) characters.
Regardless of the number of test data items the decorator only needs a a single test execution method (test_method in the example) is required. The Framework replicates this method into the multiple test methods on the decorated class.
The framework does require the test function to be wrapped in method which accepts the attributes from the input_data iterator - in the example below this wrapping function is test_method_wrapper. As shown in the example, the wrapper function it does not need to do anything at all other than wrap the test function, and accept the test data as a set of arguments which can then be used by the wrapped test function.
The unittest.TestCase class being decorated by the Framework can be entirely empty (as in the example), or it can include set Up and clear down methods as required by the test cases, or it could even include one or more hand-written test case methods (so long as the method names do not clash).
Further Information
Troubleshooting & Bugs
License
This software is covered by the provisions of Apache Software License 2.0 License.
Metadata
Release files for Repeated-Test-Framework 0.1.1rc2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| Repeated_Test_Framework-0.1.1rc2-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for Repeated_Test_Framework-0.1.1rc2-py2.py3-none-any.whl |
Release files / Repeated_Test_Framework-0.1.1rc2-py2.py3-none-any.whl
| Download URL | Repeated_Test_Framework-0.1.1rc2-py2.py3-none-any.whl |
|---|---|
| Size | 11.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
725326e68aa7fbc1a1dcc2c38d4aea85685d9b0a5683ac49ee2884af4f155b9a
|
|
BLAKE2b-256 checksum How to use checksums |
d58b76dd30223ef6deebea157708b8d7a9821e797a679726628518f29d59d0be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for Repeated-Test-Framework 0.1.1rc2
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.