testing bottle apps

9 views
Skip to first unread message

Joel Pitt

unread,
May 31, 2010, 5:17:38 PM5/31/10
to bott...@googlegroups.com
Hi all,

I was wondering if anyone had recommendations for testing bottle-based
applications?

Mostly I'm a bit unsure about how to properly set up the bottle
environment to emulate a request. I could probably work it out, but
thought I'd ask here first to see if people have already had to deal
with this. I tend to use nosetests for unit testing, but I can use
something different if it suits better.

Any help appreciated!

Joel Pitt, PhD | http://ferrouswheel.me | +64 21 101 7308
NetEmpathy Co-founder | http://netempathy.com
OpenCog Developer | http://opencog.org
Board member, Humanity+ | http://humanityplus.org

Joel Pitt

unread,
Jun 1, 2010, 8:04:54 PM6/1/10
to bott...@googlegroups.com
On Tue, Jun 1, 2010 at 9:17 AM, Joel Pitt <joel...@gmail.com> wrote:
> I was wondering if anyone had recommendations for testing bottle-based
> applications?
>
> Mostly I'm a bit unsure about how to properly set up the bottle
> environment to emulate a request. I could probably work it out, but
> thought I'd ask here first to see if people have already had to deal
> with this. I tend to use nosetests for unit testing, but I can use
> something different if it suits better.

I'll answer my own question, turns out it's pretty simple to start
with! All you need to do is:

from bottle import app
result = app().handle('/',method='GET')

I've yet to find out what will start happening if I want to test file
uploads and other more complicated things. I'll update this thread if
I learn more stuff that could be useful.

Cheers,
J

Roman Yakovenko

unread,
Jun 1, 2010, 11:57:28 PM6/1/10
to bott...@googlegroups.com

It would be really great!

Thanks
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/

Marcel Hellkamp

unread,
Jun 2, 2010, 6:32:24 AM6/2/10
to bott...@googlegroups.com
Am Dienstag, den 01.06.2010, 09:17 +1200 schrieb Joel Pitt:
> I was wondering if anyone had recommendations for testing bottle-based
> applications?

Testing WSGI applications is a common task. There are several libraries
and testing frameworks available: http://wsgi.org/wsgi/Testing

I use a custom toolbox for testing bottle itself. It is not pretty, but
it works well:

http://github.com/defnull/bottle/blob/master/test/tools.py


--
Mit freundlichen Grüßen
Marcel Hellkamp

Reply all
Reply to author
Forward
0 new messages