Issue #495 resolved

Tutorial tests fail

Robert Brewer
created an issue

{{{ C:\Python24\Lib\site-packages>python cherrypy\test\test_tutorials.py 21/Mar/2006:11:01:31 CONFIG INFO Server parameters: 21/Mar/2006:11:01:31 CONFIG INFO server.environment: development 21/Mar/2006:11:01:31 CONFIG INFO server.log_to_screen: True 21/Mar/2006:11:01:31 CONFIG INFO server.log_file: 21/Mar/2006:11:01:31 CONFIG INFO server.log_tracebacks: True 21/Mar/2006:11:01:31 CONFIG INFO server.log_request_headers: True 21/Mar/2006:11:01:31 CONFIG INFO server.protocol_version: HTTP/1.0 21/Mar/2006:11:01:31 CONFIG INFO server.socket_host: 21/Mar/2006:11:01:31 CONFIG INFO server.socket_port: 8080 21/Mar/2006:11:01:31 CONFIG INFO server.socket_file: 21/Mar/2006:11:01:31 CONFIG INFO server.reverse_dns: False 21/Mar/2006:11:01:31 CONFIG INFO server.socket_queue_size: 5 21/Mar/2006:11:01:31 CONFIG INFO server.thread_pool: 10 . ERROR: expected body: 'Hello world!'

actual body: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">\n<html>\n<head>\n <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>\n <title>404 Not F ound</title>\n <style type="text/css">\n #powered_by {\n margin-top: 20px;\n border-top: 2px solid b lack;\n font-style: italic;\n }\n\n #traceback {\n color: red;\n }\n </style>\n</head>\n <b ody>\n <h2>404 Not Found</h2>\n <p>The path \'/showMessage\' was not found.</p>\n <pre id="tracebac k"></pre>\n <div id="powered_by">\n <span>Powered by <a href="http://www.cherrypy.org">CherryPy 2.2.0rc1</a></span

\n </div>\n </body>\n</html>\n' Show: [B]ody [H]eaders [S]tatus [U]RL; [I]gnore, [R]aise, or sys.e[X]it >> R F ERROR: expected body: "Hey Bob, what's up?"

actual body: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">\n<html>\n<head>\n <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>\n <title>404 Not F ound</title>\n <style type="text/css">\n #powered_by {\n margin-top: 20px;\n border-top: 2px solid b lack;\n font-style: italic;\n }\n\n #traceback {\n color: red;\n }\n </style>\n</head>\n <b ody>\n <h2>404 Not Found</h2>\n <p>The path \'/greetUser\' was not found.</p>\n <pre id="traceback"

</pre>\n <div id="powered_by">\n <span>Powered by <a href="http://www.cherrypy.org">CherryPy 2.2.0rc1</a></span>\ n </div>\n </body>\n</html>\n' Show: [B]ody [H]eaders [S]tatus [U]RL; [I]gnore, [R]aise, or sys.e[X]it >> R F.. ERROR: expected body: 'Hendrik Mans, CherryPy co-developer & crazy German (<a href="./">back</a>)'

actual body: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">\n<html>\n<head>\n <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>\n <title>404 Not F ound</title>\n <style type="text/css">\n #powered_by {\n margin-top: 20px;\n border-top: 2px solid b lack;\n font-style: italic;\n }\n\n #traceback {\n color: red;\n }\n </style>\n</head>\n <b ody>\n <h2>404 Not Found</h2>\n <p>The path \'/hendrik\' was not found.</p>\n <pre id="traceback">< /pre>\n <div id="powered_by">\n <span>Powered by <a href="http://www.cherrypy.org">CherryPy 2.2.0rc1</a></span>\n </div>\n </body>\n</html>\n' Show: [B]ody [H]eaders [S]tatus [U]RL; [I]gnore, [R]aise, or sys.e[X]it >> R F.. ERROR: expected body: '<html>\n <body>\n myFile length: 5<br />\n myFile filename: hello.txt<br />\n m yFile mime-type: text/plain\n </body>\n </html>'

actual body: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">\n<html>\n<head>\n <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>\n <title>404 Not F ound</title>\n <style type="text/css">\n #powered_by {\n margin-top: 20px;\n border-top: 2px solid b lack;\n font-style: italic;\n }\n\n #traceback {\n color: red;\n }\n </style>\n</head>\n <b ody>\n <h2>404 Not Found</h2>\n <p>The path \'/upload\' was not found.</p>\n <pre id="traceback"></ pre>\n <div id="powered_by">\n <span>Powered by <a href="http://www.cherrypy.org">CherryPy 2.2.0rc1</a></span>\n </div>\n </body>\n</html>\n' Show: [B]ody [H]eaders [S]tatus [U]RL; [I]gnore, [R]aise, or sys.e[X]it >> R FF ====================================================================== FAIL: test02ExposeMethods (main.TutorialTest)


Traceback (most recent call last): File "c:\Python24\lib\site-packages\cherrypy\test\webtest.py", line 223, in call testMethod() File "cherrypy\test\test_tutorials.py", line 37, in test02ExposeMethods self.assertBody('Hello world!') File "c:\Python24\lib\site-packages\cherrypy\test\webtest.py", line 286, in assertBody self._handlewebError(msg) File "c:\Python24\lib\site-packages\cherrypy\test\webtest.py", line 199, in _handlewebError raise self.failureException(msg) AssertionError: expected body: 'Hello world!'

actual body: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">\n<html>\n<head>\n <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>\n <title>404 Not F ound</title>\n <style type="text/css">\n #powered_by {\n margin-top: 20px;\n border-top: 2px solid b lack;\n font-style: italic;\n }\n\n #traceback {\n color: red;\n }\n </style>\n</head>\n <b ody>\n <h2>404 Not Found</h2>\n <p>The path \'/showMessage\' was not found.</p>\n <pre id="tracebac k"></pre>\n <div id="powered_by">\n <span>Powered by <a href="http://www.cherrypy.org">CherryPy 2.2.0rc1</a></span

\n </div>\n </body>\n</html>\n'

====================================================================== FAIL: test03GetAndPost (main.TutorialTest)


Traceback (most recent call last): File "c:\Python24\lib\site-packages\cherrypy\test\webtest.py", line 223, in call testMethod() File "cherrypy\test\test_tutorials.py", line 44, in test03GetAndPost self.assertBody("Hey Bob, what's up?") File "c:\Python24\lib\site-packages\cherrypy\test\webtest.py", line 286, in assertBody self._handlewebError(msg) File "c:\Python24\lib\site-packages\cherrypy\test\webtest.py", line 199, in _handlewebError raise self.failureException(msg) AssertionError: expected body: "Hey Bob, what's up?"

actual body: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">\n<html>\n<head>\n <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>\n <title>404 Not F ound</title>\n <style type="text/css">\n #powered_by {\n margin-top: 20px;\n border-top: 2px solid b lack;\n font-style: italic;\n }\n\n #traceback {\n color: red;\n }\n </style>\n</head>\n <b ody>\n <h2>404 Not Found</h2>\n <p>The path \'/greetUser\' was not found.</p>\n <pre id="traceback"

</pre>\n <div id="powered_by">\n <span>Powered by <a href="http://www.cherrypy.org">CherryPy 2.2.0rc1</a></span>\ n </div>\n </body>\n</html>\n'

====================================================================== FAIL: test06DefaultMethod (main.TutorialTest)


Traceback (most recent call last): File "c:\Python24\lib\site-packages\cherrypy\test\webtest.py", line 223, in call testMethod() File "cherrypy\test\test_tutorials.py", line 96, in test06DefaultMethod self.assertBody('Hendrik Mans, CherryPy co-developer & crazy German ' File "c:\Python24\lib\site-packages\cherrypy\test\webtest.py", line 286, in assertBody self._handlewebError(msg) File "c:\Python24\lib\site-packages\cherrypy\test\webtest.py", line 199, in _handlewebError raise self.failureException(msg) AssertionError: expected body: 'Hendrik Mans, CherryPy co-developer & crazy German (<a href="./">back</a>)'

actual body: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">\n<html>\n<head>\n <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>\n <title>404 Not F ound</title>\n <style type="text/css">\n #powered_by {\n margin-top: 20px;\n border-top: 2px solid b lack;\n font-style: italic;\n }\n\n #traceback {\n color: red;\n }\n </style>\n</head>\n <b ody>\n <h2>404 Not Found</h2>\n <p>The path \'/hendrik\' was not found.</p>\n <pre id="traceback">< /pre>\n <div id="powered_by">\n <span>Powered by <a href="http://www.cherrypy.org">CherryPy 2.2.0rc1</a></span>\n </div>\n </body>\n</html>\n'

====================================================================== FAIL: test09Files (main.TutorialTest)


Traceback (most recent call last): File "c:\Python24\lib\site-packages\cherrypy\test\webtest.py", line 223, in call testMethod() File "cherrypy\test\test_tutorials.py", line 134, in test09Files self.assertBody('''<html> File "c:\Python24\lib\site-packages\cherrypy\test\webtest.py", line 286, in assertBody self._handlewebError(msg) File "c:\Python24\lib\site-packages\cherrypy\test\webtest.py", line 199, in _handlewebError raise self.failureException(msg) AssertionError: expected body: '<html>\n <body>\n myFile length: 5<br />\n myFile filename: hello.txt<br />\n m yFile mime-type: text/plain\n </body>\n </html>'

actual body: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">\n<html>\n<head>\n <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>\n <title>404 Not F ound</title>\n <style type="text/css">\n #powered_by {\n margin-top: 20px;\n border-top: 2px solid b lack;\n font-style: italic;\n }\n\n #traceback {\n color: red;\n }\n </style>\n</head>\n <b ody>\n <h2>404 Not Found</h2>\n <p>The path \'/upload\' was not found.</p>\n <pre id="traceback"></ pre>\n <div id="powered_by">\n <span>Powered by <a href="http://www.cherrypy.org">CherryPy 2.2.0rc1</a></span>\n </div>\n </body>\n</html>\n'

====================================================================== FAIL: test10HTTPErrors (main.TutorialTest)


Traceback (most recent call last): File "c:\Python24\lib\site-packages\cherrypy\test\webtest.py", line 223, in call testMethod() File "cherrypy\test\test_tutorials.py", line 161, in test10HTTPErrors self.assertEqual(cherrypy.config.get('server.show_tracebacks'), not tracebacks) AssertionError: False != True


Ran 10 tests in 8.101s

FAILED (failures=5) 21/Mar/2006:11:01:40 ENGINE INFO SystemExit raised: shutting down autoreloader 21/Mar/2006:11:01:40 ENGINE INFO CherryPy shut down }}}

Comments (3)

  1. Christian Wyglendowski

    The problem comes down to the CherryPy app server being started with nothing mounted at cherrypy.root. I actually noticed this when I was doing my interactive CherryPy screencast, but I didn't really consider it a bug at the time. I suppose it could be frustrating for someone doing something "creative" with CP.

    Also, I think that test_tutorials should set server.environment = 'production'.

  2. Log in to comment