vendor be available at a specific URL. See "Setting Up Databases" below
for details.
-The py.test Engine
+The pytest Engine
==================
-Both the tox runner and the setup.py runner are using py.test to invoke
-the test suite. Within the realm of py.test, SQLAlchemy itself is adding
-a large series of option and customizations to the py.test runner using
-plugin points, to allow for SQLAlchemy's multiple database support,
-database setup/teardown and connectivity, multi process support, as well as
-lots of skip / database selection rules.
+The tox runner is using pytest to invoke the test suite. Within the realm of
+pytest, SQLAlchemy itself is adding a large series of option and
+customizations to the pytest runner using plugin points, to allow for
+SQLAlchemy's multiple database support, database setup/teardown and
+connectivity, multi process support, as well as lots of skip / database
+selection rules.
-Running tests with py.test directly grants more immediate control over
+Running tests with pytest directly grants more immediate control over
database options and test selection.
-A generic py.test run looks like::
+A generic pytest run looks like::
- py.test -n4
+ pytest -n4
Above, the full test suite will run against SQLite, using four processes.
If the "-n" flag is not used, the pytest-xdist is skipped and the tests will
run linearly, which will take a pretty long time.
-The py.test command line is more handy for running subsets of tests and to
+The pytest command line is more handy for running subsets of tests and to
quickly allow for custom database connections. Example::
- py.test --dburi=postgresql+psycopg2://scott:tiger@localhost/test test/sql/test_query.py
+ pytest --dburi=postgresql+psycopg2://scott:tiger@localhost/test test/sql/test_query.py
Above will run the tests in the test/sql/test_query.py file (a pretty good
file for basic "does this database work at all?" to start with) against a
running PostgreSQL database at the given URL.
-The py.test frontend can also run tests against multiple kinds of databases
-at once - a large subset of tests are marked as "backend" tests, which will
-be run against each available backend, and additionally lots of tests are targeted
-at specific backends only, which only run if a matching backend is made available.
-For example, to run the test suite against both PostgreSQL and MySQL at the same time::
+The pytest frontend can also run tests against multiple kinds of databases at
+once - a large subset of tests are marked as "backend" tests, which will be run
+against each available backend, and additionally lots of tests are targeted at
+specific backends only, which only run if a matching backend is made available.
+For example, to run the test suite against both PostgreSQL and MySQL at the
+same time::
- py.test -n4 --db postgresql --db mysql
+ pytest -n4 --db postgresql --db mysql
Setting Up Databases
The test suite identifies several built-in database tags that run against
a pre-set URL. These can be seen using --dbs::
- $ py.test --dbs=.
+ $ pytest --dbs
Available --db options (use --dburi to override)
default sqlite:///:memory:
firebird firebird://sysdba:masterkey@localhost//Users/classic/foo.fdb
Above, we can now run the tests with ``my_postgresql``::
- py.test --db my_postgresql
+ pytest --db my_postgresql
We can also override the existing names in our ``test.cfg`` file, so that we can run
with the tox runner also::
======================
The test runner will by default create and drop tables within the default
-database that's in the database URL, *unless* the multiprocessing option
-is in use via the py.test "-n" flag, which invokes pytest-xdist. The
-multiprocessing option is **enabled by default** for both the tox runner
-and the setup.py frontend. When multiprocessing is used, the SQLAlchemy
-testing framework will create a new database for each process, and then
-tear it down after the test run is complete. So it will be necessary
-for the database user to have access to CREATE DATABASE in order for this
-to work.
+database that's in the database URL, *unless* the multiprocessing option is in
+use via the pytest "-n" flag, which invokes pytest-xdist. The
+multiprocessing option is **enabled by default** when using the tox runner.
+When multiprocessing is used, the SQLAlchemy testing framework will create a
+new database for each process, and then tear it down after the test run is
+complete. So it will be necessary for the database user to have access to
+CREATE DATABASE in order for this to work. Additionally, as mentioned
+earlier, the database URL must be formatted such that it can be rewritten on
+the fly to refer to these other databases, which means for pyodbc it must refer
+to a hostname/database name combination, not a DSN name.
Several tests require alternate usernames or schemas to be present, which
are used to test dotted-name access scenarios. On some databases such
Any log target can be directed to the console with command line options, such
as::
- $ ./py.test test/orm/test_unitofwork.py -s \
+ $ ./pytest test/orm/test_unitofwork.py -s \
--log-debug=sqlalchemy.pool --log-info=sqlalchemy.engine
-Above we add the py.test "-s" flag so that standard out is not suppressed.
+Above we add the pytest "-s" flag so that standard out is not suppressed.
DEVELOPING AND TESTING NEW DIALECTS