HaveF / feedparser

Automatically exported from code.google.com/p/feedparser
Other
0 stars 0 forks source link

HTTP server for unit tests runs on 0.0.0.0 #315

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Not very nice. Here's a patch!

--- feedparser/feedparsertest.py    (revision 672)
+++ feedparser/feedparsertest.py    (working copy)
@@ -58,6 +58,7 @@
 #---------- custom HTTP server (used to serve test feeds) ----------

 _PORT = 8097 # not really configurable, must match hardcoded port in tests
+_HOST = "localhost" # see above

 class FeedParserTestRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
     headers_re = re.compile(_s2bytes(r"^Header:\s+([^:]+):(.+)$"), re.MULTILINE)
@@ -109,7 +110,7 @@
         self.ready = threading.Event()

     def run(self):
-        self.httpd = BaseHTTPServer.HTTPServer(('', _PORT), 
FeedParserTestRequestHandler)
+        self.httpd = BaseHTTPServer.HTTPServer((_HOST, _PORT), 
FeedParserTestRequestHandler)
         self.ready.set()
         while self.requests:
             self.httpd.handle_request()
@@ -662,7 +663,7 @@
                     httpcount -= 1 + (xmlfile in wellformedfiles)
                 continue
             if ishttp:
-                xmlfile = 'http://127.0.0.1:%s/%s' % (_PORT, 
posixpath.normpath(xmlfile.replace('\\', '/')))
+                xmlfile = 'http://%s:%s/%s' % (_HOST, _PORT, 
posixpath.normpath(xmlfile.replace('\\', '/')))
             testFunc = buildTestCase(xmlfile, description, evalString)
             if isinstance(addTo, tuple):
                 setattr(addTo[0], testName, testFunc)

Original issue reported on code.google.com by jo...@bergstroem.nu on 8 Dec 2011 at 3:12

GoogleCodeExporter commented 9 years ago
That was sloppy. use _HOST = "127.0.0.1" instead. thanks.

Original comment by jo...@bergstroem.nu on 8 Dec 2011 at 3:16

GoogleCodeExporter commented 9 years ago
You are on *fire* today! :) I ran into this being a problem while testing 
IronPython, but never pursued it further. Thanks for the excellent patch! By 
the way, I've been slowly compiling a list of contributors; based on your 
website, I should credit you as Johan Bergström, right?

Fixed in r674.

Original comment by kurtmckee on 8 Dec 2011 at 4:26

GoogleCodeExporter commented 9 years ago
*blushes*
Was only doing my job as version bumper for gentoo and ran into some issues 
with the test suite. Johan Bergström (bugs@same domain if needed) will do. 
Thanks! 

Original comment by jo...@bergstroem.nu on 8 Dec 2011 at 4:29