'Check if variable remains in locals after removed from script'

def test_local_variable(self):

    self.widget.execute_button.checkbox.setCheckState(False)
    self.widget.text.setPlainText('temp    =    42\nprint(temp)')
    self.widget.execute_button.button.click()
    self.assertIn('42', self.widget.console.toPlainText())
    self.widget.text.setPlainText('print(temp)')
    self.widget.execute_button.button.click()
    self.assertNotIn("NameError:    name    'temp'    is    not    defined", self.widget.console.toPlainText())
