From adb3d4f71cefedb00b95b63a44b7237feb49ba5a Mon Sep 17 00:00:00 2001 From: Vinicius Assef Date: Tue, 5 Nov 2013 06:05:16 -0200 Subject: [PATCH] =?UTF-8?q?A=20better=20README.=20Thanks,=20Richard=20V?= =?UTF-8?q?=C3=A9zina?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 93 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 80 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 1b44dba..f75e044 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +Web2py.test +=========== + An example of how to test an Web2py Application. @@ -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. @@ -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 +