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))
    def handle(self, statement: st.Statement) -> None:
        """Actually handle the given statement.

        Args:
            statement: the statement that is visited.

        """
        value = self._exec_ctx.get_variable_value(self._variable)
        if is_primitive_type(type(value)):
            return

        self._trace.add_entry(
            statement.get_position(),
            self._variable,
            nte.NoneTraceEntry(self._variable, value is None),
        )
def test_hash_neq():
    variable = MagicMock()
    assert hash(nte.NoneTraceEntry(variable, False)) != hash(
        nte.NoneTraceEntry(variable, True))
def test_hash():
    variable = MagicMock()
    assert hash(nte.NoneTraceEntry(variable, True)) == hash(
        nte.NoneTraceEntry(variable, True))
def test_neq():
    variable = MagicMock()
    assert nte.NoneTraceEntry(variable, False) != nte.NoneTraceEntry(
        variable, True)
def test_eq():
    variable = MagicMock()
    assert nte.NoneTraceEntry(variable,
                              True) == nte.NoneTraceEntry(variable, True)
def test_get_assertions():
    variable = MagicMock()
    entry = nte.NoneTraceEntry(variable, True)
    assertions = entry.get_assertions()
    assert assertions == {nas.NoneAssertion(variable, True)}
def test_clone():
    variable = MagicMock()
    entry = nte.NoneTraceEntry(variable, True)
    cloned = entry.clone()
    assert cloned == nte.NoneTraceEntry(variable, True)
def test_init():
    variable = MagicMock()
    entry = nte.NoneTraceEntry(variable, True)
    assert entry._variable == variable
    assert entry._is_none