Python testing for humans
Neither of the two most popular libraries for testing in Python, unittest and pytest, make it over the hurdle of the Zen of Python.
Beautiful is better than ugly.
Explicit is better than implicit.
unittest is modeled closely on JUnit and the xUnit family of libraries. Its strength is its familiarity to people who are accustomed to them. Its weakness is its failure to take advantage of existing Python idioms and conventions. It's not beautiful.
Pytest addresses a lot of the shortcomings of unittest, but the way that its fixtures work is magical, especially when they are imported invisibly. It doesn't make it past the second line of the Zen of Python.
Testsweet intends to be a Python testing library that uses existing Python features and idioms: A kind and simple interface, explicit in its architecture, enabling the tests that use it to be beautiful.
A test function:
from testsweet import test
@test
def or_dicts():
assert {'foo': 1} | {'bar': 2} == {'foo': 1, 'bar': 2}A test class:
from testsweet import test
@test
class OrThings:
def or_dicts(self):
assert {'foo': 1} | {'bar': 2} == {'foo': 1, 'bar': 2}Running tests:
testsweet tests.test_module.TestClass.test_method
testsweet tests/test_module.py
testsweet # Discover testspython -m testsweet ... works equivalently and is useful when the
console script is not on PATH.
