summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_robotparser.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2017-11-23 23:57:58 (GMT)
committerRaymond Hettinger <rhettinger@users.noreply.github.com>2017-11-23 23:57:58 (GMT)
commitff847d1ac7e6a8ee1fb6f8883cfb4aec4b4a9b03 (patch)
tree977839c6cf63c20540af78240c219ccd39a190cc /Lib/test/test_robotparser.py
parenta645b23ffc76073a2eb4e77b88cb7648cfc6ef77 (diff)
downloadcpython-ff847d1ac7e6a8ee1fb6f8883cfb4aec4b4a9b03.zip
cpython-ff847d1ac7e6a8ee1fb6f8883cfb4aec4b4a9b03.tar.gz
cpython-ff847d1ac7e6a8ee1fb6f8883cfb4aec4b4a9b03.tar.bz2
bpo-31325: Fix usage of namedtuple in RobotFileParser.parse() (GH-4529) (#4533)
(cherry picked from commit 3df02dbc8e197053105f9dffeae40b04ec66766e)
Diffstat (limited to 'Lib/test/test_robotparser.py')
-rw-r--r--Lib/test/test_robotparser.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/test/test_robotparser.py b/Lib/test/test_robotparser.py
index 0f64ba8..e47344c 100644
--- a/Lib/test/test_robotparser.py
+++ b/Lib/test/test_robotparser.py
@@ -2,7 +2,6 @@ import io
import os
import unittest
import urllib.robotparser
-from collections import namedtuple
from test import support
from http.server import BaseHTTPRequestHandler, HTTPServer
try:
@@ -90,6 +89,10 @@ class BaseRequestRateTest(BaseRobotTest):
self.parser.crawl_delay(agent), self.crawl_delay
)
if self.request_rate:
+ self.assertIsInstance(
+ self.parser.request_rate(agent),
+ urllib.robotparser.RequestRate
+ )
self.assertEqual(
self.parser.request_rate(agent).requests,
self.request_rate.requests
@@ -111,7 +114,7 @@ Disallow: /a%2fb.html
Disallow: /%7ejoe/index.html
"""
agent = 'figtree'
- request_rate = namedtuple('req_rate', 'requests seconds')(9, 30)
+ request_rate = urllib.robotparser.RequestRate(9, 30)
crawl_delay = 3
good = [('figtree', '/foo.html')]
bad = ['/tmp', '/tmp.html', '/tmp/a.html', '/a%3cd.html', '/a%3Cd.html',
@@ -240,7 +243,7 @@ Crawl-delay: 1
Request-rate: 3/15
Disallow: /cyberworld/map/
"""
- request_rate = namedtuple('req_rate', 'requests seconds')(3, 15)
+ request_rate = urllib.robotparser.RequestRate(3, 15)
crawl_delay = 1
good = ['/', '/test.html']
bad = ['/cyberworld/map/index.html']