[Python-checkins] cpython (3.3): #17066: test_robotparser now works with unittest test discovery. Patch by
ezio.melotti
python-checkins at python.org
Tue Mar 12 06:51:05 CET 2013
http://hg.python.org/cpython/rev/fa051c6276a0
changeset: 82625:fa051c6276a0
branch: 3.3
parent: 82621:e9ada209b67f
user: Ezio Melotti <ezio.melotti at gmail.com>
date: Tue Mar 12 07:49:12 2013 +0200
summary:
#17066: test_robotparser now works with unittest test discovery. Patch by Zachary Ware.
files:
Lib/test/test_robotparser.py | 16 ++++++++++------
Misc/NEWS | 3 +++
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/Lib/test/test_robotparser.py b/Lib/test/test_robotparser.py
--- a/Lib/test/test_robotparser.py
+++ b/Lib/test/test_robotparser.py
@@ -6,7 +6,10 @@
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 @@
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()
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -662,6 +662,9 @@
- Issue #15539: Added regression tests for Tools/scripts/pindent.py.
+- Issue #17066: test_robotparser now works with unittest test discovery.
+ Patch by Zachary Ware.
+
- Issue #17334: test_index now works with unittest test discovery.
Patch by Zachary Ware.
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list