-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-128731: fix ResourceWarning in test_robotparser
#128746
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -334,16 +334,17 @@ def tearDown(self): | |
self.server.shutdown() | ||
self.t.join() | ||
self.server.server_close() | ||
self.parser.close() # P9de7 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. |
||
|
||
@threading_helper.reap_threads | ||
def testPasswordProtectedSite(self): | ||
addr = self.server.server_address | ||
url = 'http://' + socket_helper.HOST + ':' + str(addr[1]) | ||
robots_url = url + "/robots.txt" | ||
parser = urllib.robotparser.RobotFileParser() | ||
parser.set_url(url) | ||
parser.read() | ||
self.assertFalse(parser.can_fetch("*", robots_url)) | ||
self.parser = urllib.robotparser.RobotFileParser() # P9de7 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's "P9de7"? |
||
self.parser.set_url(url) | ||
self.parser.read() | ||
self.assertFalse(self.parser.can_fetch("*", robots_url)) | ||
|
||
|
||
@support.requires_working_socket() | ||
|
@@ -364,6 +365,9 @@ def url(self, path): | |
self.base_url, path, '/' if not os.path.splitext(path)[1] else '' | ||
) | ||
|
||
def tearDown(self): | ||
self.parser.close() # P080b | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's P080b? |
||
|
||
def test_basic(self): | ||
self.assertFalse(self.parser.disallow_all) | ||
self.assertFalse(self.parser.allow_all) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be removed. We want to warn when there is a resource that is not closed. What should be fixed are the tests where we should explicitly close the corresponding resources.