summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_robotparser.py
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2013-03-12 05:49:12 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2013-03-12 05:49:12 (GMT)
commit0fb37ea34d260d817520578057ab79dc97f780ff (patch)
tree132d86d802014fbc2de9c86bda3b118f4c0340c8 /Lib/test/test_robotparser.py
parent0f84764a09401bb93f544141a433db5acd751dd2 (diff)
downloadcpython-0fb37ea34d260d817520578057ab79dc97f780ff.zip
cpython-0fb37ea34d260d817520578057ab79dc97f780ff.tar.gz
cpython-0fb37ea34d260d817520578057ab79dc97f780ff.tar.bz2
#17066: test_robotparser now works with unittest test discovery. Patch by Zachary Ware.
Diffstat (limited to 'Lib/test/test_robotparser.py')
-rw-r--r--Lib/test/test_robotparser.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/Lib/test/test_robotparser.py b/Lib/test/test_robotparser.py
index 178761d..8c09e74 100644
--- a/Lib/test/test_robotparser.py
+++ b/Lib/test/test_robotparser.py
@@ -6,7 +6,10 @@ from urllib.request import urlopen
from test import support
class RobotTestCase(unittest.TestCase):
- def __init__(self, index, parser, url, good, agent):
+ def __init__(self, index=None, parser=None, url=None, good=None, agent=None):
+ # workaround to make unittest discovery work (see #17066)
+ if not isinstance(index, int):
+ return
unittest.TestCase.__init__(self)
if good:
self.str = "RobotTest(%d, good, %s)" % (index, url)
@@ -269,10 +272,11 @@ class NetworkTestCase(unittest.TestCase):
self.assertTrue(
parser.can_fetch("*", "http://www.python.org/robots.txt"))
-def test_main():
- support.run_unittest(NetworkTestCase)
- support.run_unittest(tests)
+def load_tests(loader, suite, pattern):
+ suite = unittest.makeSuite(NetworkTestCase)
+ suite.addTest(tests)
+ return suite
if __name__=='__main__':
- support.verbose = 1
- test_main()
+ support.use_resources = ['network']
+ unittest.main()