Skip to content

A reasonable way to implement and run test cases in a Web2py application, using py.test

License

Notifications You must be signed in to change notification settings

gorosz/web2py.test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

An example of how to test an Web2py Application.

I use py.test [1] to test this application, but the concept can be applied in unittest and nose, too.

This work was done using Web2py v 2.4.5

IMPORTANT: I recommend you working with virtualenv to give you more freedom. It's not required, but strongly recommended.

The procedure to run tests present for this application is:

  1. create a new virtualenv. Let's call it web2py.test
  2. $ cd web2py.test
  3. $ source bin/activate
  4. $ pip install pytest (it will install py.test just in your virtualenv)
  5. download web2py stable [2]
  6. unzip web2py to your web2py.test/web2py dir
  7. clone this repo to web2py.test/web2py/applications/people subdir
  8. $ cd web2py (you must be in web2py root directory to run tests)
  9. $ python web2py.py -a my_password --nogui &
  10. $ py.test -x -v -s applications/people/tests

Voilà!

To understand the method used to allow run tests, refer to web2py/applications/people/tests/conftest.py

Read web2py/applications/people/models/db.py to see how to make your application know she is running under the test environment.

Test cases are in web2py/applications/people/tests subdirs.

Links used in this doc:

About

A reasonable way to implement and run test cases in a Web2py application, using py.test

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published