首页 > 其他分享 >解决:ResourceWarning: Enable tracemalloc to get the object allocation traceback

解决:ResourceWarning: Enable tracemalloc to get the object allocation traceback

时间:2022-10-28 19:01:55浏览次数:51  
标签:Enable get tearDown self anaconda3 Selenium allocation ResourceWarning

发现一个很有意思的事情:

    def tearDown(self):
        self.driver.close()

会报错:

/opt/homebrew/anaconda3/envs/Selenium/bin/python /Users/mokin.li/PycharmProjects/pythonProject/main.py 
./opt/homebrew/anaconda3/envs/Selenium/lib/python3.9/unittest/suite.py:84: ResourceWarning: unclosed <socket.socket fd=6, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('127.0.0.1', 56646), raddr=('127.0.0.1', 56642)>
  return self.run(*args, **kwds)
ResourceWarning: Enable tracemalloc to get the object allocation traceback

----------------------------------------------------------------------
Ran 1 test in 17.560s

OK

但是将tearDown中的内容进行修改:

    def tearDown(self):
        self.driver.quit()

最后的返回结果:

/opt/homebrew/anaconda3/envs/Selenium/bin/python /Users/mokin.li/PycharmProjects/pythonProject/main.py 
.
----------------------------------------------------------------------
Ran 1 test in 17.397s

OK

Process finished with exit code 0

有趣有趣~

要去看看quit() & close()

标签:Enable,get,tearDown,self,anaconda3,Selenium,allocation,ResourceWarning
From: https://www.cnblogs.com/MoKinLi/p/16837125.html

相关文章