web2py unit testing

web2py의 unit testing은 다른 web frameworks 에 비해서 좀 까다로운 면이 있지만 그리 어렵진 않다.

까다롭다고 하는 이유는 prepared environment때문인데 아래 코드처럼 사용해야 하는 global object들 execfile을 통해서 만들어줘야 한다는 것이다.

import unittest

from gluon.globals import Request

execfile("applications/api/controllers/10.py", globals())

Anthony가 정리해놓은 아래 링크들 확인.

http://web2py.com/AlterEgo/default/show/260
http://packages.python.org/web2py_utils/test_runner.html
http://www.web2pyslices.com/slices/take_slice/142

Happy Coding~:)

Advertisements

About rookiecj

Hi all. Today is the day.
This entry was posted in python, testing, web2py and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s