Unit-testing Framework
pip install bentests@git+https://github.com/ben-251/ben-tests.gitpip install --upgrade --force-reinstall bentests@git+https://github.com/ben-251/ben-tests.gitImport as with any library:
import bentests as bGroup tests with classes:
class FloatTests(b.testGroup):
def testAlmostRight(self):
b.assertAlmostEquals(1.0001,1,error_margin=3)
class ArithmeticTests(b.testGroup):
def testSubtraction(self):
b.assertEquals(1,2-1)
def testZeroDivision(self):
with b.assertRaises(ZeroDivisionError):
v = 1/0 Run tests in their groups:
b.test_all(FloatTests, ArithmeticTests, stats_amount="high")Example Output:
Starting tests..
Running tests in "FloatTests":
Test passed.
Running tests in "ArithmeticTests":
Both tests passed.
Tests Complete.
3 Tests run in 2 Groups:
All Tests Passed.