def default_test_case_with_assertions(default_test_case):
    float0 = prim.FloatPrimitiveStatement(default_test_case, 5.5)
    default_test_case.add_statement(float0)
    float0ass0 = pas.PrimitiveAssertion(float0.ret_val, 5.5)
    float0ass1 = pas.PrimitiveAssertion(float0.ret_val, 6)
    float0.add_assertion(float0ass0)
    float0.add_assertion(float0ass1)

    float1 = prim.FloatPrimitiveStatement(default_test_case, 5.5)
    default_test_case.add_statement(float1)

    float2 = prim.FloatPrimitiveStatement(default_test_case, 5.5)
    default_test_case.add_statement(float2)
    float2ass0 = pas.PrimitiveAssertion(float2.ret_val, 5.5)
    float2.add_assertion(float2ass0)
    return default_test_case, {float0ass0, float0ass1, float2ass0}
def test_clone():
    source = MagicMock()
    cloned_ref = MagicMock()
    source.clone.return_value = cloned_ref
    assertion = pa.PrimitiveAssertion(source, 1337)
    new_test_case = MagicMock()
    cloned = assertion.clone(new_test_case, 20)
    source.clone.assert_called_with(new_test_case, 20)
    assert cloned.source == cloned_ref
    assert cloned.value == 1337
def simple_test_case(constructor_mock):
    test_case = dtc.DefaultTestCase()
    int_stmt = prim_stmt.IntPrimitiveStatement(test_case, 5)
    constructor_stmt = param_stmt.ConstructorStatement(test_case,
                                                       constructor_mock,
                                                       [int_stmt.return_value])
    constructor_stmt.add_assertion(
        pas.PrimitiveAssertion(constructor_stmt.return_value, 3))
    test_case.add_statement(int_stmt)
    test_case.add_statement(constructor_stmt)
    return test_case
def simple_test_case(function_mock) -> dtc.DefaultTestCase:
    test_case = dtc.DefaultTestCase()
    int_prim = prim.IntPrimitiveStatement(test_case, 5)
    int_prim2 = prim.IntPrimitiveStatement(test_case, 5)
    float_prim = prim.FloatPrimitiveStatement(test_case, 5.5)
    func = ps.FunctionStatement(test_case, function_mock, [float_prim.ret_val])
    func.add_assertion(pas.PrimitiveAssertion(func.ret_val, 3.1415))
    string_prim = prim.StringPrimitiveStatement(test_case, "Test")
    string_prim.ret_val.variable_type = type(None)
    test_case.add_statement(int_prim)
    test_case.add_statement(int_prim2)
    test_case.add_statement(float_prim)
    test_case.add_statement(func)
    test_case.add_statement(string_prim)
    return test_case
Example #5
0
def test_get_assertions():
    variable = MagicMock()
    entry = pte.PrimitiveTraceEntry(variable, True)
    assertions = entry.get_assertions()
    assert assertions == {pas.PrimitiveAssertion(variable, True)}
Example #6
0
 def get_assertions(self) -> Set[ass.Assertion]:
     return {pas.PrimitiveAssertion(self._variable, self._value)}
def test_accept():
    visitor = MagicMock()
    assertion = pa.PrimitiveAssertion(MagicMock(), 1337)
    assertion.accept(visitor)
    visitor.visit_primitive_assertion.assert_called_with(assertion)