#17066: merge with 3.3.

This commit is contained in:
Ezio Melotti 2013-03-12 07:50:53 +02:00
commit 0ce306abf3
2 changed files with 13 additions and 6 deletions

View file

@ -6,7 +6,10 @@ from urllib.request import urlopen
from test import support from test import support
class RobotTestCase(unittest.TestCase): 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) unittest.TestCase.__init__(self)
if good: if good:
self.str = "RobotTest(%d, good, %s)" % (index, url) self.str = "RobotTest(%d, good, %s)" % (index, url)
@ -269,10 +272,11 @@ class NetworkTestCase(unittest.TestCase):
self.assertTrue( self.assertTrue(
parser.can_fetch("*", "http://www.python.org/robots.txt")) parser.can_fetch("*", "http://www.python.org/robots.txt"))
def test_main(): def load_tests(loader, suite, pattern):
support.run_unittest(NetworkTestCase) suite = unittest.makeSuite(NetworkTestCase)
support.run_unittest(tests) suite.addTest(tests)
return suite
if __name__=='__main__': if __name__=='__main__':
support.verbose = 1 support.use_resources = ['network']
test_main() unittest.main()

View file

@ -934,6 +934,9 @@ Tests
- Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host. - Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host.
- Issue #17066: test_robotparser now works with unittest test discovery.
Patch by Zachary Ware.
- Issue #17334: test_index now works with unittest test discovery. - Issue #17334: test_index now works with unittest test discovery.
Patch by Zachary Ware. Patch by Zachary Ware.