ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
preprocessor.unittest_mixin Namespace Reference

Classes

class  UnittestMixin

Functions

 _compare (op)
 _compare_none (op)
 _isinstance (obj, cls)
 _typed_equal (type_name)
 _not (expr)
 _is_names (expr)
 _bind_arguments (call, params)

Variables

str _CASE_VAR_PREFIX = "__ESBMC_unittest_case_"
str _ARG_VAR_PREFIX = "__ESBMC_unittest_arg_"
tuple _SCOPES = (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef)
dict _ASSERTIONS

Detailed Description

Expansion of unittest.main() and inlining of TestCase assertions.

Function Documentation

◆ _bind_arguments()

preprocessor.unittest_mixin._bind_arguments ( call,
params )
protected
Map *call*'s arguments to *params* and msg, or None if they do not fit.

◆ _compare()

preprocessor.unittest_mixin._compare ( op)
protected

◆ _compare_none()

preprocessor.unittest_mixin._compare_none ( op)
protected

◆ _is_names()

preprocessor.unittest_mixin._is_names ( expr)
protected

◆ _isinstance()

preprocessor.unittest_mixin._isinstance ( obj,
cls )
protected

◆ _not()

preprocessor.unittest_mixin._not ( expr)
protected

◆ _typed_equal()

preprocessor.unittest_mixin._typed_equal ( type_name)
protected

Variable Documentation

◆ _ARG_VAR_PREFIX

str preprocessor.unittest_mixin._ARG_VAR_PREFIX = "__ESBMC_unittest_arg_"
protected

◆ _ASSERTIONS

dict preprocessor.unittest_mixin._ASSERTIONS
protected
Initial value:
1= {
2 "assertEqual": (("first", "second"), _compare(ast.Eq)),
3 "assertNotEqual": (("first", "second"), _compare(ast.NotEq)),
4 "assertTrue": (("expr", ), lambda e: [e]),
5 "assertFalse": (("expr", ), lambda e: [_not(e)]),
6 "assertIs": (("expr1", "expr2"), _compare(ast.Is)),
7 "assertIsNot": (("expr1", "expr2"), _compare(ast.IsNot)),
8 "assertIsNone": (("obj", ), _compare_none(ast.Is)),
9 "assertIsNotNone": (("obj", ), _compare_none(ast.IsNot)),
10 "assertIn": (("member", "container"), _compare(ast.In)),
11 "assertNotIn": (("member", "container"), _compare(ast.NotIn)),
12 "assertLess": (("a", "b"), _compare(ast.Lt)),
13 "assertLessEqual": (("a", "b"), _compare(ast.LtE)),
14 "assertGreater": (("a", "b"), _compare(ast.Gt)),
15 "assertGreaterEqual": (("a", "b"), _compare(ast.GtE)),
16 "assertIsInstance": (("obj", "cls"), lambda o, c: [_isinstance(o, c)]),
17 "assertNotIsInstance": (("obj", "cls"), lambda o, c: [_not(_isinstance(o, c))]),
18 "assertListEqual": (("list1", "list2"), _typed_equal("list")),
19 "assertTupleEqual": (("tuple1", "tuple2"), _typed_equal("tuple")),
20 "assertDictEqual": (("d1", "d2"), _typed_equal("dict")),
21 "assertMultiLineEqual": (("first", "second"), _typed_equal("str")),
22 "fail": ((), lambda: [ast.Constant(value=False)]),
23}

◆ _CASE_VAR_PREFIX

str preprocessor.unittest_mixin._CASE_VAR_PREFIX = "__ESBMC_unittest_case_"
protected

◆ _SCOPES

tuple preprocessor.unittest_mixin._SCOPES = (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef)
protected