Chapter 96. unittest
This is a basic unit testing library. It can be used to crreate and run regression tests for functions with various cases.
testcase
Description
Type Tags
testcase
Object Value
Objects of type testcase have no value, and it is an error to try to get or set this value.
testcase.new()
Description
Prototype
testcase
.new
(
testcase
,
string me
,
function name
,
type(*) test
)
testref
Parameters
Parameter | Default value | Type name | Description |
---|---|---|---|
me | None | testcase | |
name | None | string | |
test | None | function | |
testref | None | type(*) |
Properties
Property | Type | Description |
---|---|---|
addvalue | function | |
cleanup | function | |
defaultTestResult | function | |
description | string | |
fail | function | |
failIf | function | |
failIfAlmostEqual | function | |
failIfEqual | function | |
failUnless | function | |
failUnlessAlmostEqual | function | |
failUnlessEqual | function | |
failUnlessError | function | |
failureError | integer | |
name | string | |
reporteqerror | function | |
reporteqerror_datetimes | function | |
result | string | |
run | function | |
setup | function | |
test | function | |
testref | type(*) | |
type | type | |
values | list |
Methods
addvalue()
Description
Prototype
testcasevar
.addvalue
(
testcase
,
type(testcasevalue) me
)
v
Parameters
Parameter | Default value | Type name | Description |
---|---|---|---|
me | None | testcase | |
v | None | type(testcasevalue) |
reporteqerror()
Description
Prototype
testcasevar
.reporteqerror
(
testcase
,
integer me
,
type(=) id
,
type(=) expected
)
result
Parameters
Parameter | Default value | Type name | Description |
---|---|---|---|
me | None | testcase | |
id | None | integer | |
expected | None | type(=) | |
result | None | type(=) |
reporteqerror_datetimes()
Description
Prototype
testcasevar
.reporteqerror_datetimes
(
testcase
,
integer me
,
type(*) id
,
type(*) expected
,
function result
,
string evalfunc
)
pattern
Parameters
Parameter | Default value | Type name | Description |
---|---|---|---|
me | None | testcase | |
id | None | integer | |
expected | None | type(*) | |
result | None | type(*) | |
evalfunc | None | function | |
pattern | None | string |
run()
Description
Prototype
testcasevar
.run
(
testcase
)
me
Parameters
Parameter | Default value | Type name | Description |
---|---|---|---|
me | None | testcase |