Tests usually require a database access. Tests use the database named in test.ini- usually format of
This PostgreSQL database must be created before the test run. It is not dropped, but is cleaned, from the content between individual tests.
Create test database on OSX¶
Create test database on Ubuntu¶
sudo -u postgres createdb myapp_dev
Use py.test command.
py.test should be available in
bin of your virtual environment if you installed your Websauna application package with
pip install -e ".[test]".
Example to run all tests for
myapp package. Run the following in the package root folder:
py.test myapp --ini conf/test.ini
Example to run a single test using
-k regex match of test names:
py.test myapp --ini conf/test.ini -k test_login
Pytest buffers stdout by default and you will miss all print and log statements. If you wish to see these use
py.test myapp --ini conf/test.ini -s
If you are running multiple tests and want to abort after first failing test use
py.test myapp --ini conf/test.ini -x