How to unit test using Bottle system
2 answers
The bottle lacks some of the testing subtleties that Flask has (see here) . But Bottle recommends using the WSGI Testing Tools along with the regular unit testing framework ( http://bottlepy.org/docs/dev/recipes.html#functional-testing-bottle-applications ). You won't have access to bottle syntax or parameters passed to templates, etc., but you won't need to run a separate server either.
+1
source to share
Use boddle for unit testing if you want to access the syntax of a regular bottle. Example:
import bottle, unittest
from boddle import boddle
@bottle.get('/woot')
def woot():
return bottle.request.params['name']
class TestIt(unittest.TestCase):
def testWoot(self):
with boddle(params={'name':'derek'}):
self.assertEqual(woot(), 'derek')
if __name__=='__main__':
unittest.main()
0
source to share