Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Diff of /examples/web_framework/web_framework.tst [9ac085] .. [0176eb] Maximize Restore

  Switch to side-by-side view

--- a/examples/web_framework/web_framework.tst
+++ b/examples/web_framework/web_framework.tst
@@ -12,12 +12,13 @@
     ...                           stdout=subprocess.PIPE,
     ...                           stderr=subprocess.STDOUT,
     ...                           close_fds=True, env=os.environ)
-    >>> server.stdin.write(r'''
+    >>> server.stdin.write(('''
     ... import sys
     ... sys.path.insert(0, %r)
     ... from examples.web_framework import simple_server
     ... simple_server.run()
-    ... ''' % sys.path[0])
+    ... ''' % sys.path[0]).encode()) > 110
+    True
     >>> server.stdin.close()
     >>> def readline():
     ...     global server_error_msg
@@ -31,8 +32,8 @@
     ...           "Server terminated prematurely with returncode %r\n" % \
     ...             (server.returncode,))
     ...         return
-    ...     line = server.stdout.readline()
-    ...     print >> sys.stderr, line,
+    ...     line = server.stdout.readline().decode()
+    ...     print(line, end='', file=sys.stderr)
     ...     return line
     >>> while True:
     ...     line = readline()
@@ -44,16 +45,16 @@
 
 Then interact with it:
 
-    >>> import urllib
+    >>> import urllib.request
     >>> def get(path):
-    ...     f = urllib.urlopen("http://localhost:8080/" + path)
-    ...     #print >> sys.stderr, "info:", tuple(sorted(f.info().keys()))
+    ...     f = urllib.request.urlopen("http://localhost:8080/" + path)
+    ...     #print("info:", tuple(sorted(f.info().keys())), file=sys.stderr)
     ...     try:
-    ...         return f.read() # int(f.info()['content-length']))
+    ...         return f.read().decode() # int(f.info()['content-length']))
     ...     finally:
     ...         f.close()
 
-    >>> print get("movie/1/movie.html")
+    >>> print(get("movie/1/movie.html"))
     <html>
       <head>
         <title>It's a Mad, Mad, Mad, Mad World</title>
@@ -76,9 +77,9 @@
     >>> readline()        # doctest: +ELLIPSIS
     "get_plan(..., ('movie',), ...examples/web_framework/movie.html)\n"
     >>> readline()        # doctest: +ELLIPSIS
-    'localhost - - [...] "GET /movie/1/movie.html HTTP/1.0" 200 302\n'
+    'localhost - - [...] "GET /movie/1/movie.html HTTP/1.1" 200 302\n'
 
-    >>> print get("movie/3/movie.html")
+    >>> print(get("movie/3/movie.html"))
     <html>
       <head>
         <title>A Funny Thing Happened on the Way to the Forum</title>
@@ -99,9 +100,9 @@
     <BLANKLINE>
 
     >>> readline()        # doctest: +ELLIPSIS
-    'localhost - - [...] "GET /movie/3/movie.html HTTP/1.0" 200 332\n'
+    'localhost - - [...] "GET /movie/3/movie.html HTTP/1.1" 200 332\n'
 
-    >>> print get("movie/3/movie2.html")
+    >>> print(get("movie/3/movie2.html"))
     <html>
       <head>
         <title>A Funny Thing Happened on the Way to the Forum</title>
@@ -131,9 +132,9 @@
     >>> readline()        # doctest: +ELLIPSIS
     "get_plan(..., ('movie',), ...examples/web_framework/movie2.html)\n"
     >>> readline()        # doctest: +ELLIPSIS
-    'localhost - - [...] "GET /movie/3/movie2.html HTTP/1.0" 200 429\n'
+    'localhost - - [...] "GET /movie/3/movie2.html HTTP/1.1" 200 429\n'
 
-    >>> print get("movie/6/movie2.html")
+    >>> print(get("movie/6/movie2.html"))
     <html>
       <head>
         <title>Casino Royale</title>
@@ -169,7 +170,7 @@
     <BLANKLINE>
 
     >>> readline()        # doctest: +ELLIPSIS
-    'localhost - - [...] "GET /movie/6/movie2.html HTTP/1.0" 200 485\n'
+    'localhost - - [...] "GET /movie/6/movie2.html HTTP/1.1" 200 485\n'
 
 Kill server: