python中:UnboundLocalError: local variable ‘fp‘ referenced before assignment




```def run(self):
        try:
            suit=self.set_case_suite()
            print("try")
            print(str(suit))
            if suit is not None:
                print("if-suite")
                fp=open(resultPath,'wb')
                runner=HtmlTestRunner.HTMLTestRunner(stream='fp',title='Test Report',description='Test description')
                runner.run(suit)
            else:
                print("have no case to test.")
        except Exception as ex:
          print(str(ex))
        finally:
            print("**********test end!**********")
            fp.close()
        #判断邮件发送的开关:
        if on_off=="on":
            send_
```python



```mail.send_email()
        else:
            print("邮件发送配置开关关闭,请打开邮件配置开关后再次发送邮件")
————————————————