Skip to content

Commit

Permalink
A better README. Thanks, Richard Vézina
Browse files Browse the repository at this point in the history
  • Loading branch information
viniciusban committed Nov 5, 2013
1 parent 1c635bc commit adb3d4f
Showing 1 changed file with 80 additions and 13 deletions.
93 changes: 80 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Web2py.test
===========


An example of how to test an Web2py Application.

Expand All @@ -7,29 +10,93 @@ Tested in Web2py v2.7.4

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



## Stepping into

The procedure to run tests present for this application is:

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

1. Create a new virtualenv. Let's call it bla:

`
$ cd ~
$ mkdir -p virtualenvs/bla
$ cd virtualenvs/bla
$ virtualenv .
`

1. Enter into it:

`
$ source bin/activate
`

1. Now your prompt should look like this:

`
(bla)username@yourmachine:~$
`

1. Install py.test just in your virtualenv:

`
$ pip install pytest
`

1. Download latest web2py stable:

`
$ wget http://www.web2py.com/examples/static/web2py_src.zip
`

1. Unzip it:

`
$ unzip web2py_src.zip
`

1. Now you must see web2py dir created inside your current dir.
1. Enter into it:

`
$ cd web2py
`

1. Get the latest web2py.test:

`
$ git clone https://github.com/viniciusban/web2py.test.git applications/people
`

1. You must see the people dir inside your applications directory.
1. Start Web2py development server:

`
$ python web2py.py -a my_password --nogui &
`

1. Run tests:

`
$ 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



## Understanding

To understand the method used to allow running 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.


There are 3 important parts in this application:
There are 4 important parts in this application:

1. tests/conftest.py -> configure test environment.
1. modules/web2pytest/web2pytest.py -> test infrastructure.
Expand All @@ -39,4 +106,4 @@ There are 3 important parts in this application:
Links used in this doc:

- [1] http://pytest.org
- [2] http://web2py.com/init/default/download

0 comments on commit adb3d4f

Please sign in to comment.