testing Package

testing Package

array_extended_test Module

class contracts.testing.array_extended_test.ArrayTest(methodName='runTest')[source]

Bases: unittest.case.TestCase

setUp()[source]
test_correct_behavior()[source]
test_incorrect1()[source]
test_incorrect2()[source]
test_incorrect3()[source]
test_incorrect4()[source]
test_incorrect5()[source]
test_incorrect6()[source]
contracts.testing.array_extended_test.blend_function(image1, image2, bug=False)[source]

Blends two RGB or RGBA images together.

param image1:The first image to blend.
type image1:(rgb|rgba),array[HxWx*]
param image2:The second image to blend.
type image2:(rgb|rgba),array[HxWx*]
param bug:Introduce a bug to check the contracts.
type bug:bool
return:The blended image.
rtype:rgb,array[HxWx3]

friendliness_statistics Module

contracts.testing.friendliness_statistics.get_all_strings()[source]
contracts.testing.friendliness_statistics.main()[source]
contracts.testing.friendliness_statistics.replace_one(s, i, c)[source]
contracts.testing.friendliness_statistics.run_joker(examples)[source]

test_class_contracts Module

class contracts.testing.test_class_contracts.ClassContractsTests(methodName='runTest')[source]

Bases: unittest.case.TestCase

test_class_contract1()[source]
test_class_contract1_bad()[source]

example of bad usage, using the contract from outside

test_class_contract2()[source]
test_class_contract3()[source]

test_decorator Module

class contracts.testing.test_decorator.DecoratorTests(methodName='runTest')[source]

Bases: unittest.case.TestCase

not_supported1()[source]

Support of *args

not_supported2()[source]

Support of **args

test_bad_quoting()[source]
test_bad_quoting2()[source]
test_check_docstring_maintained()[source]
test_check_it_works1()[source]
test_check_it_works2()[source]
test_check_it_works2b()[source]

Nothing for b

test_check_it_works2c()[source]

Nothing for b

test_check_it_works3()[source]
test_empty_types()[source]
test_empty_types2()[source]
test_inline_docstring_format_works()[source]
test_invalid1()[source]
test_invalid_args()[source]
test_invalid_args2()[source]

unknown parameter

test_keywords()[source]
test_kwargs()[source]
test_malformed()[source]
test_malformed2()[source]
test_not_specified1()[source]

No docstring specified

test_not_specified2()[source]
test_ok1()[source]
test_ok2()[source]
test_ok3()[source]

Trying the quoting thing.

test_parse_error1()[source]
test_parse_error2()[source]
test_same_signature()[source]
test_too_many()[source]
test_varargs()[source]

test_docstring_parsing Module

class contracts.testing.test_docstring_parsing.DocStringTest(methodName='runTest')[source]

Bases: unittest.case.TestCase

test_inline_params()[source]
test_inline_returns()[source]
test_number_of_spaces()[source]
test_parsing()[source]
test_reparsing()[source]

test_idioms Module

class contracts.testing.test_idioms.TestIdioms(methodName='runTest')[source]

Bases: unittest.case.TestCase

test_binding()[source]
test_check_1()[source]
test_check_1a()[source]
test_check_2()[source]
test_check_3()[source]
test_check_4()[source]
test_check_context()[source]
test_check_context2()[source]

Variable names must have only one letter.

test_check_multiple_1()[source]
test_equality_contract()[source]
test_equality_rvalue()[source]
test_parse_1()[source]
test_parse_2()[source]
test_repr_1()[source]

test_multiple Module

Other testing examples

test_new_contract Module

class contracts.testing.test_new_contract.TestNewContract(methodName='runTest')[source]

Bases: unittest.case.TestCase

counter = 0
test_allow_renaming_if_equal1()[source]
test_allow_renaming_if_equal2()[source]
test_as_decorator()[source]
test_as_decorator_multiple()[source]
test_as_decorator_with_args()[source]
test_as_decorator_with_args_and_kwargs()[source]
test_as_decorator_with_kwargs()[source]
test_callable()[source]
test_callable1()[source]
test_callable2()[source]
test_callable3()[source]
test_callable4()[source]
test_callable_5()[source]
test_callable_old_style()[source]
test_capital_name1()[source]
test_capital_name2()[source]
test_class_as_contract1()[source]
test_class_as_contract2()[source]
test_class_as_contract3()[source]
test_class_as_contract4()[source]
test_idioms()[source]
test_invalid_callable()[source]
test_invalid_callable2()[source]
test_invalid_names()[source]
test_inverted_args()[source]
test_lambda_2()[source]
test_lambda_invalid()[source]
test_other_pass()[source]
test_parsing_error()[source]
test_parsing_error2()[source]
test_renaming()[source]
test_separate_context()[source]
test_types_as_contracts()[source]
test_types_as_contracts2()[source]
test_valid()[source]
test_well_recognized()[source]
test_wrong_args()[source]
contracts.testing.test_new_contract.check_valid_identifier(e)[source]
contracts.testing.test_new_contract.cname()[source]
contracts.testing.test_new_contract.fail1(x)[source]
contracts.testing.test_new_contract.fail2(x)[source]
contracts.testing.test_new_contract.invalid_callable1(x)[source]
contracts.testing.test_new_contract.ok1(x)[source]
contracts.testing.test_new_contract.ok2(x)[source]
contracts.testing.test_new_contract.test_valid_identifiers()[source]

test_particulars Module

class contracts.testing.test_particulars.TestBindingVsRef(methodName='runTest')[source]

Bases: unittest.case.TestCase

test_binding_vs_ref()[source]
test_binding_vs_ref2()[source]
class contracts.testing.test_particulars.TestParticular(methodName='runTest')[source]

Bases: unittest.case.TestCase

test_partial()[source]
test_variable_parseable()[source]
test_variables()[source]
contracts.testing.test_particulars.expression_fails(expression, string, all=True)[source]
contracts.testing.test_particulars.expression_parses(expression, string, all=True)[source]

test_pickling Module

contracts.testing.test_pickling.check_contract_pickable(contract)[source]
contracts.testing.test_pickling.check_exception_pickable(contract, value)[source]
contracts.testing.test_pickling.test_contracts_are_pickable()[source]
contracts.testing.test_pickling.test_exceptions_are_pickable()[source]

test_simple Module

contracts.testing.test_simple.check_good_repr(c)[source]

Checks that we can eval() the __repr__() value and we get an equivalent object.

contracts.testing.test_simple.check_recoversion(s, exact)[source]

Checks that we can eval() the __repr__() value and we get an equivalent object.

contracts.testing.test_simple.test_contract_fail()[source]
contracts.testing.test_simple.test_good()[source]
contracts.testing.test_simple.test_reconversion()[source]
contracts.testing.test_simple.test_repr()[source]
contracts.testing.test_simple.test_semantic_fail()[source]
contracts.testing.test_simple.test_syntax_fail()[source]

utils Module

contracts.testing.utils.check_contracts_fail(contract, value, error=<class 'contracts.interface.ContractNotRespected'>)[source]

Returns the exception

contracts.testing.utils.check_contracts_ok(contract, value)[source]
contracts.testing.utils.check_syntax_fail(string)[source]