简体   繁体   English

ResourceWarning:运行python selenium unittest时出现未关闭的文件错误

[英]ResourceWarning: unclosed file error while running python selenium unittest

While running python selenium unittest I'm seeing an error:在运行 python selenium unittest 时,我看到一个错误:

/usr/lib/python3.6/unittest/case.py:605: ResourceWarning: unclosed file <_io.TextIOWrapper name='/home/newuser/scable/HTML_Test_Runner_ReportTest.html' mode='w' encoding='UTF-8'>
  testMethod()
.
----------------------------------------------------------------------
Ran 1 test in 0.006s

OK
sys:1: ResourceWarning: unclosed <socket.socket fd=4, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('127.0.0.1', 42230), raddr=('127.0.0.1', 34255)>

What does this error means?这个错误是什么意思?

This error message...这个错误信息...

/usr/lib/python3.6/unittest/case.py:605: ResourceWarning: unclosed file

...implies that there was a ResourceWarning while trying to access an unclosed file . ...暗示在尝试访问未关闭的文件时出现ResourceWarning


This issue is specific to as the ResourceWarnings are only emitted with Python3 .此问题特定于因为ResourceWarnings仅随Python3发出。 The most probhable reason is, you have opened a file, used it, but then forgot to close the file.最可能的原因是,您打开了一个文件,使用了它,但后来忘记关闭该文件。 Though Python automatically closes the opened file on behalf of you when it notices that the file object is dead but this occurs after some significant time has elapsed.尽管Python在注意到文件对象已死时会自动代表您关闭打开的文件,但这发生在经过一段时间后。

This issue can also occur specifically on if you try to perform some operations in a file which is still open eg trying to delete a file.如果您尝试在仍然打开的文件中执行某些操作(例如尝试删除文件),则此问题也可能发生在

However, this issue seems to arising as you try to open the file HTML_Test_Runner_ReportTest.html when the file was still under process.但是,当您在文件仍在处理过程中尝试打开文件HTML_Test_Runner_ReportTest.html时,似乎会出现此问题。

A simple solution would be to wait for the HTML_Test_Runner_ReportTest.html file to be completely processed and then access it.一个简单的解决方案是等待HTML_Test_Runner_ReportTest.html文件被完全处理,然后访问它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未关闭但 UnitTest 正在抛出它的文件的 ResourceWarning - ResourceWarning for a file that is unclosed but UnitTest is throwing it Python 3单元测试中的ResourceWarning未关闭套接字 - ResourceWarning unclosed socket in Python 3 Unit Test Vanilla Django 在日志记录中抛出 ResourceWarning: “unclosed file” - Vanilla Django casts a ResourceWarning: “unclosed file” on logging ResourceWarning:未关闭的文件 &lt;_io.BufferedReader name=4&gt; - ResourceWarning: unclosed file <_io.BufferedReader name=4> Python3:Reportlab图像 - ResourceWarning:未闭合文件&lt;_io.BufferedReader name = ...&gt; - Python3: Reportlab Image - ResourceWarning: unclosed file <_io.BufferedReader name=…> Python 3:ResourceWarning:unclosed文件<_io.TextIOWrapper name ='PATH_OF_FILE' - Python 3: ResourceWarning: unclosed file <_io.TextIOWrapper name='PATH_OF_FILE' 莫名其妙的ResourceWarning:未关闭的文件&lt;_io.TextIOWrapper名称= 3 - Inexplicable ResourceWarning: unclosed file <_io.TextIOWrapper name=3 记录在何处打开文件以调试“ ResourceWarning:未关闭的文件” - Record where files are opened to debug “ResourceWarning: unclosed file” 如何在单元测试下运行的 doctest 中抑制 ResourceWarning()s - How to suppress ResourceWarning()s in doctest running under unittest FileNotFoundError:运行unittest python时 - FileNotFoundError : while running unittest python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM