def test_handle_primitive():
    exec_ctx = MagicMock()
    exec_ctx.get_variable_value.return_value = 5
    variable = MagicMock()
    trace = MagicMock()
    visitor = nao.NoneAssertionVisitor(exec_ctx, variable, trace)
    statement = MagicMock()
    visitor.handle(statement)
    trace.add_entry.assert_not_called()
def test_visits_unimplemented(method):
    exec_ctx = MagicMock()
    exec_ctx.get_variable_value.return_value = 5
    variable = MagicMock()
    trace = MagicMock()
    visitor = nao.NoneAssertionVisitor(exec_ctx, variable, trace)
    statement = MagicMock()
    with mock.patch.object(visitor, "handle"):
        with pytest.raises(NotImplementedError):
            getattr(visitor, method)(statement)
def test_visits(method, call_count):
    exec_ctx = MagicMock()
    exec_ctx.get_variable_value.return_value = 5
    variable = MagicMock()
    trace = MagicMock()
    visitor = nao.NoneAssertionVisitor(exec_ctx, variable, trace)
    statement = MagicMock()
    with mock.patch.object(visitor, "handle") as handle_mock:
        getattr(visitor, method)(statement)
        assert handle_mock.call_count == call_count
def test_handle_not_primitive_none():
    exec_ctx = MagicMock()
    exec_ctx.get_variable_value.return_value = None
    variable = MagicMock()
    trace = MagicMock()
    visitor = nao.NoneAssertionVisitor(exec_ctx, variable, trace)
    statement = MagicMock()
    statement.get_position.return_value = 42
    visitor.handle(statement)
    trace.add_entry.assert_called_with(42, variable,
                                       nte.NoneTraceEntry(variable, True))