M
M
maxclax2015-07-16 21:20:39
Django
maxclax, 2015-07-16 21:20:39

How to properly test django with splinter?

I am using Django 1.8 and selenium.
The workflow is as follows:
- BDD scripts (pytest-bdd) written;
- written steps for tests (pytest-splinter)
- settings file has DB configuration

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    },
}

I run the tests:
1 I run the server itself (runserver)
2 I run the tests themselves (py.test)
As a result, this is what I get: the server is running on the database from the settings. All fixtures and the database stand on a separate database, and the tests are trying to pass to the database from a running server. What am I doing wrong? This was not the case with Django 1.7. But with the release of 1.8, it began to separate the database.
Even if I specify in the DB settings for tests ( djbook.ru/rel1.8/topics/testing/overview.html ) the result is the same due to the fact that the server raises the default database, and the database for tests on each step resets.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2015-07-16
@maxclax

Try to move away from fixtures - no one likes to update them
create a config for tests and inherit it from the base
config progname/settings/
__init__.py
base.py
dev.py
test.py
will launch the skulllight in memory
you will need to run the test pack like this
./manage. py test --settings=progname.settings.test
./manage.py runserver --settings=progname.settings.dev

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question