As you are testing the real application you get the answer you would get
when serving the request,
so in case of exceptions the exception is trapped to serve an error 500
page.

If you have "debug=True" the page will actually be the interactive
debugger, so at the end of the error response (after </html>) you should
see something like:

<!--

Traceback (most recent call last):
  [...]
  File "/media/sf_wrk/TESTS/plain/plain/controllers/root.py", line 59, in
crash
    raise RuntimeError('Something Bad!')
RuntimeError: Something Bad!

-->

Which is the actual traceback of the error.

If you are working with debug=false (so in the same situation of the
production environment) then no error is injected (to avoid exposing
security relevant information to the user), so everything is swallowed by
the /error/document page. In that case, If you want to get the crash and
not the 500 page you must set handle_error_page = False in your test suite
configuration.

On Sun, Feb 22, 2015 at 3:35 AM, NIWDEK <[email protected]> wrote:

> Hi All,
>
> I am trying to use TDD to develop an app using TG2.
>
> The test is like this
>
>
>     def test_home_page_should_have_an_input_form_to_submit_message(self):
>         resp = self.app.get('/')
>         form = resp.form
>         form['message'] = 'Message to be sent.'
>         send_message = form.submit(status=302)
>         ok_(send_message.location.startswith('http://localhost/'))
>         result_page = send_message.follow()
>         ok_("Message sent" in result_page.text)
>
> However, when I have error in RootController.index(), I just got server
> 500 like following
>
> Traceback (most recent call last):
>   File
> "/Users/xxx/.virtualenvs/message-broadcaster/lib/python3.3/site-packages/nose/case.py",
> line 198, in runTest
>     self.test(*self.arg)
>   File "/Users/xxx/.pyenv/versions/3.3.2/lib/python3.3/unittest/mock.py",
> line 1087, in patched
>     return func(*args, **keywargs)
>   File
> "/Users/xxx/Workspace/message-broadcaster/message-broadcaster/messagebroadcaster/tests/functional/test_root.py",
> line 28, in test_home_page_should_have_an_input_form
>     send_message = form.submit(status=302)
>   File
> "/Users/xxx/.virtualenvs/message-broadcaster/lib/python3.3/site-packages/webtest/app.py",
> line 1708, in submit
>     params=fields, **args)
>   File
> "/Users/xxx/.virtualenvs/message-broadcaster/lib/python3.3/site-packages/webtest/app.py",
> line 369, in goto
>     return method(href, **args)
>   File
> "/Users/xxx/.virtualenvs/message-broadcaster/lib/python3.3/site-packages/webtest/app.py",
> line 838, in post
>     content_type=content_type)
>   File
> "/Users/xxx/.virtualenvs/message-broadcaster/lib/python3.3/site-packages/webtest/app.py",
> line 810, in _gen_request
>     expect_errors=expect_errors)
>   File
> "/Users/xxx/.virtualenvs/message-broadcaster/lib/python3.3/site-packages/webtest/app.py",
> line 1121, in do_request
>     self._check_status(status, res)
>   File
> "/Users/xxx/.virtualenvs/message-broadcaster/lib/python3.3/site-packages/webtest/app.py",
> line 1160, in _check_status
>     "Bad response: %s (not %s)", res_status, status)
> nose.proxy.AppError: Bad response: 500 INTERNAL SERVER ERROR (not 302)
>
>
> It is not quite useful for me to debug. I would like to have something
> like sqlalchemy.exc.OperationalError with backtrace, which can tell me
> which line causes the error occurs. Right now, I can only start the server
> and simulate the test in browser to figure out what causes the server 500.
> How can I get more useful information when running functional test?
>
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "TurboGears" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/turbogears.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.

Reply via email to