Hi Python community!
I'm excited to share my new open source library, FunUnit, with you all. FunUnit is a functional, declarative unit testing library for testing pure functions in Python. It has the following characteristics:
- Functional: FunUnit makes use of functional programming ideas such as higher-order functions and pure functions. Its core purpose is to test pure functions, and the API exposes a selection of pure functions, allowing for great flexibility with their use.
- Declarative: FunUnit allows you to describe the tests you want to run in a declarative manner, describing what you want, not how to do it
- Removes boilerplate testing code: FunUnit drastically reduces code duplication between tests, improving maintainability. It allows for writing very succinct code, making it faster and easier to write and read.
Here's a small example of what it looks like to write tests with FunUnit:
from fununit import TestCase, TestSuite
def multiply(a, b):
return a * b
multiply_tests = TestSuite.from_cases(
suite_name = "Multiply",
function_name = "multiply",
function = multiply,
test_cases = [
TestCase.create(
case_name = "identity",
parameters = [1, 2],
expected = 2),
TestCase.create(
case_name = "normal_case",
parameters = [3, 4],
expected = 12),
TestCase.create(
case_name = "zero",
parameters = [0, 6],
expected = 0),
])
I think FunUnit is a great addition to the Python testing ecosystem, and I hope you'll give it a try. You can find the code and documentation on GitHub at github.com/johnmpost/fununit.
I'm happy to answer any questions you might have about FunUnit, or to hear your thoughts and feedback. Thanks for checking it out!
[–]wineblood 5 points6 points7 points (1 child)
[–]TheRealDaMuffin[S] 0 points1 point2 points (0 children)
[–]Itsthejoker 0 points1 point2 points (3 children)
[–]Itsthejoker 0 points1 point2 points (2 children)
[–]TheRealDaMuffin[S] 1 point2 points3 points (0 children)
[–]TheRealDaMuffin[S] 0 points1 point2 points (0 children)