Skip to content

Travis: also test on MyISAM #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 63 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@ env:
- DB=sqlite DJANGO_VERSION=1.6.1 PSYCOPG_VERSION=2.4.5
- DB=sqlite DJANGO_VERSION=master PSYCOPG_VERSION=2.4.5

- DB=mysql DJANGO_VERSION=1.3.5 PSYCOPG_VERSION=2.4.1
- DB=mysql DJANGO_VERSION=1.4.3 PSYCOPG_VERSION=2.4.5
- DB=mysql DJANGO_VERSION=1.5.2 PSYCOPG_VERSION=2.4.5
- DB=mysql DJANGO_VERSION=1.6.1 PSYCOPG_VERSION=2.4.5
- DB=mysql DJANGO_VERSION=master PSYCOPG_VERSION=2.4.5
- DB=mysql_innodb DJANGO_VERSION=1.3.5 PSYCOPG_VERSION=2.4.1
- DB=mysql_innodb DJANGO_VERSION=1.4.3 PSYCOPG_VERSION=2.4.5
- DB=mysql_innodb DJANGO_VERSION=1.5.2 PSYCOPG_VERSION=2.4.5
- DB=mysql_innodb DJANGO_VERSION=1.6.1 PSYCOPG_VERSION=2.4.5
- DB=mysql_innodb DJANGO_VERSION=master PSYCOPG_VERSION=2.4.5

- DB=mysql_myisam DJANGO_VERSION=1.3.5 PSYCOPG_VERSION=2.4.1
- DB=mysql_myisam DJANGO_VERSION=1.4.3 PSYCOPG_VERSION=2.4.5
- DB=mysql_myisam DJANGO_VERSION=1.5.2 PSYCOPG_VERSION=2.4.5
- DB=mysql_myisam DJANGO_VERSION=1.6.1 PSYCOPG_VERSION=2.4.5
- DB=mysql_myisam DJANGO_VERSION=master PSYCOPG_VERSION=2.4.5

- DB=postgres DJANGO_VERSION=1.3.5 PSYCOPG_VERSION=2.4.1
- DB=postgres DJANGO_VERSION=1.4.3 PSYCOPG_VERSION=2.4.5
Expand All @@ -37,7 +43,7 @@ install:
- 'if [ "$DJANGO_VERSION" == "master" ]; then pip install -e git+https://github.com/django/django@master#egg=Django; fi'
- 'if [ "$TRAVIS_PYTHON_VERSION" == "pypy" -a "$DB" == postgres ]; then pip install psycopg2ct; fi'
- 'if [ "$TRAVIS_PYTHON_VERSION" != "pypy" -a "$DB" == postgres ]; then pip install psycopg2==$PSYCOPG_VERSION; fi'
- 'if [ "$DB" == mysql ]; then pip install mysql-python; fi'
- 'if [ "$DB" == mysql_innodb -o "$DB" == mysql_myisam ]; then pip install mysql-python; fi'
- pip install -r requirements.txt

before_script:
Expand All @@ -61,63 +67,100 @@ matrix:
env: DB=postgres DJANGO_VERSION=1.5.2 PSYCOPG_VERSION=2.4.5
- python: pypy
env: DB=postgres DJANGO_VERSION=1.6.1 PSYCOPG_VERSION=2.4.5

# pypy + mysql
- python: pypy
env: DB=mysql DJANGO_VERSION=1.3.5 PSYCOPG_VERSION=2.4.1
env: DB=mysql_innodb DJANGO_VERSION=1.3.5 PSYCOPG_VERSION=2.4.1
- python: pypy
env: DB=mysql_innodb DJANGO_VERSION=1.4.3 PSYCOPG_VERSION=2.4.5
- python: pypy
env: DB=mysql_innodb DJANGO_VERSION=1.5.2 PSYCOPG_VERSION=2.4.5

- python: pypy
env: DB=mysql_myisam DJANGO_VERSION=1.3.5 PSYCOPG_VERSION=2.4.1
- python: pypy
env: DB=mysql DJANGO_VERSION=1.4.3 PSYCOPG_VERSION=2.4.5
env: DB=mysql_myisam DJANGO_VERSION=1.4.3 PSYCOPG_VERSION=2.4.5
- python: pypy
env: DB=mysql DJANGO_VERSION=1.5.2 PSYCOPG_VERSION=2.4.5
env: DB=mysql_myisam DJANGO_VERSION=1.5.2 PSYCOPG_VERSION=2.4.5

# python 3.2 + django 1.3
- python: "3.2"
env: DB=sqlite DJANGO_VERSION=1.3.5 PSYCOPG_VERSION=2.4.1
- python: "3.2"
env: DB=mysql DJANGO_VERSION=1.3.5 PSYCOPG_VERSION=2.4.1
env: DB=mysql_innodb DJANGO_VERSION=1.3.5 PSYCOPG_VERSION=2.4.1
- python: "3.2"
env: DB=mysql_myisam DJANGO_VERSION=1.3.5 PSYCOPG_VERSION=2.4.1
- python: "3.2"
env: DB=postgres DJANGO_VERSION=1.3.5 PSYCOPG_VERSION=2.4.1

# python 3.2 + django 1.4
- python: "3.2"
env: DB=sqlite DJANGO_VERSION=1.4.3 PSYCOPG_VERSION=2.4.5
- python: "3.2"
env: DB=mysql DJANGO_VERSION=1.4.3 PSYCOPG_VERSION=2.4.5
env: DB=mysql_innodb DJANGO_VERSION=1.4.3 PSYCOPG_VERSION=2.4.5
- python: "3.2"
env: DB=mysql_myisam DJANGO_VERSION=1.4.3 PSYCOPG_VERSION=2.4.5
- python: "3.2"
env: DB=postgres DJANGO_VERSION=1.4.3 PSYCOPG_VERSION=2.4.5

# python 3.2 + mysql
- python: "3.2"
env: DB=mysql DJANGO_VERSION=1.5.2 PSYCOPG_VERSION=2.4.5
env: DB=mysql_innodb DJANGO_VERSION=1.5.2 PSYCOPG_VERSION=2.4.5
- python: "3.2"
env: DB=mysql DJANGO_VERSION=1.6.1 PSYCOPG_VERSION=2.4.5
env: DB=mysql_innodb DJANGO_VERSION=1.6.1 PSYCOPG_VERSION=2.4.5
- python: "3.2"
env: DB=mysql DJANGO_VERSION=master PSYCOPG_VERSION=2.4.5
env: DB=mysql_innodb DJANGO_VERSION=master PSYCOPG_VERSION=2.4.5

- python: "3.2"
env: DB=mysql_myisam DJANGO_VERSION=1.5.2 PSYCOPG_VERSION=2.4.5
- python: "3.2"
env: DB=mysql_myisam DJANGO_VERSION=1.6.1 PSYCOPG_VERSION=2.4.5
- python: "3.2"
env: DB=mysql_myisam DJANGO_VERSION=master PSYCOPG_VERSION=2.4.5

# python 3.3 + django 1.3
- python: "3.3"
env: DB=sqlite DJANGO_VERSION=1.3.5 PSYCOPG_VERSION=2.4.1
- python: "3.3"
env: DB=mysql DJANGO_VERSION=1.3.5 PSYCOPG_VERSION=2.4.1
env: DB=mysql_innodb DJANGO_VERSION=1.3.5 PSYCOPG_VERSION=2.4.1
- python: "3.3"
env: DB=mysql_myisam DJANGO_VERSION=1.3.5 PSYCOPG_VERSION=2.4.1
- python: "3.3"
env: DB=postgres DJANGO_VERSION=1.3.5 PSYCOPG_VERSION=2.4.1

# python 3.3 + django 1.4
- python: "3.3"
env: DB=sqlite DJANGO_VERSION=1.4.3 PSYCOPG_VERSION=2.4.5
- python: "3.3"
env: DB=mysql DJANGO_VERSION=1.4.3 PSYCOPG_VERSION=2.4.5
env: DB=mysql_innodb DJANGO_VERSION=1.4.3 PSYCOPG_VERSION=2.4.5
- python: "3.3"
env: DB=mysql_myisam DJANGO_VERSION=1.4.3 PSYCOPG_VERSION=2.4.5
- python: "3.3"
env: DB=postgres DJANGO_VERSION=1.4.3 PSYCOPG_VERSION=2.4.5

# python 3.3 + mysql
- python: "3.3"
env: DB=mysql DJANGO_VERSION=1.5.2 PSYCOPG_VERSION=2.4.5
env: DB=mysql_innodb DJANGO_VERSION=1.5.2 PSYCOPG_VERSION=2.4.5
- python: "3.3"
env: DB=mysql DJANGO_VERSION=1.6.1 PSYCOPG_VERSION=2.4.5
env: DB=mysql_innodb DJANGO_VERSION=1.6.1 PSYCOPG_VERSION=2.4.5
- python: "3.3"
env: DB=mysql DJANGO_VERSION=master PSYCOPG_VERSION=2.4.5
env: DB=mysql_innodb DJANGO_VERSION=master PSYCOPG_VERSION=2.4.5

- python: "3.3"
env: DB=mysql_myisam DJANGO_VERSION=1.5.2 PSYCOPG_VERSION=2.4.5
- python: "3.3"
env: DB=mysql_myisam DJANGO_VERSION=1.6.1 PSYCOPG_VERSION=2.4.5
- python: "3.3"
env: DB=mysql_myisam DJANGO_VERSION=master PSYCOPG_VERSION=2.4.5

# Django 1.7 and Python 2.6
- python: "2.6"
env: DB=sqlite DJANGO_VERSION=master PSYCOPG_VERSION=2.4.5

- python: "2.6"
env: DB=mysql DJANGO_VERSION=master PSYCOPG_VERSION=2.4.5
env: DB=mysql_innodb DJANGO_VERSION=master PSYCOPG_VERSION=2.4.5
- python: "2.6"
env: DB=mysql_myisam DJANGO_VERSION=master PSYCOPG_VERSION=2.4.5

- python: "2.6"
env: DB=postgres DJANGO_VERSION=master PSYCOPG_VERSION=2.4.5
2 changes: 1 addition & 1 deletion pytest_django/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def db(request, _django_db_setup, _django_cursor_wrapper):
_django_cursor_wrapper.enable()
case = TestCase(methodName='__init__')
case._pre_setup()
request.addfinalizer(case._post_teardown)
request.addfinalizer(_django_cursor_wrapper.disable)
request.addfinalizer(case._post_teardown)


@pytest.fixture(scope='function')
Expand Down
File renamed without changes.
13 changes: 13 additions & 0 deletions tests/settings_mysql_myisam.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from tests.settings_base import * # noqa

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'pytest_django',
'HOST': 'localhost',
'USER': 'root',
'OPTIONS': {
'init_command': 'SET storage_engine=MyISAM'
}
},
}
20 changes: 20 additions & 0 deletions tests/test_database.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from __future__ import with_statement

from django.db import transaction, connection
from django.test.testcases import connections_support_transactions

import pytest

from .app.models import Item
Expand Down Expand Up @@ -68,9 +70,15 @@ def test_clean_db(self, both_dbs):
assert Item.objects.count() == 0

def test_transactions_disabled(self, db):
if not connections_support_transactions():
pytest.skip('transactions required for this test')

assert noop_transactions()

def test_transactions_enabled(self, transactional_db):
if not connections_support_transactions():
pytest.skip('transactions required for this test')

assert not noop_transactions()

@pytest.fixture
Expand All @@ -79,6 +87,9 @@ def mydb(self, both_dbs):
Item.objects.create(name='spam')

def test_mydb(self, mydb):
if not connections_support_transactions():
pytest.skip('transactions required for this test')

# Check the fixture had access to the db
item = Item.objects.get(name='spam')
assert item
Expand Down Expand Up @@ -111,12 +122,21 @@ def test_clean_db(self):

@pytest.mark.django_db
def test_transactions_disabled(self):
if not connections_support_transactions():
pytest.skip('transactions required for this test')

assert noop_transactions()

@pytest.mark.django_db(transaction=False)
def test_transactions_disabled_explicit(self):
if not connections_support_transactions():
pytest.skip('transactions required for this test')

assert noop_transactions()

@pytest.mark.django_db(transaction=True)
def test_transactions_enabled(self):
if not connections_support_transactions():
pytest.skip('transactions required for this test')

assert not noop_transactions()
4 changes: 4 additions & 0 deletions tests/test_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import pytest
from django.conf import settings as real_settings
from django.test.client import Client, RequestFactory
from django.test.testcases import connections_support_transactions

from .app.models import Item
from .test_database import noop_transactions
Expand Down Expand Up @@ -87,6 +88,9 @@ def test_url(self, live_server):
assert live_server.url == force_text(live_server)

def test_transactions(self, live_server):
if not connections_support_transactions():
pytest.skip('transactions required for this test')

assert not noop_transactions()

def test_db_changes_visibility(self, live_server):
Expand Down