Skip to content
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

Python 2.6 compatibility #8

Merged
merged 4 commits into from
Jun 15, 2015
Merged
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
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
sudo: false
language: python
python:
- "2.6"
- "2.7"
- "3.3"
- "3.4"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ arbitrary swappable models in your own reusable apps.
[![Build Status](https://travis-ci.org/wq/django-swappable-models.svg?branch=master)](https://travis-ci.org/wq/django-swappable-models)
[![PyPI Package](https://pypip.in/version/swapper/badge.svg?style=flat)](https://pypi.python.org/pypi/swapper)

Tested on Python 2.7 and 3.4, with Django 1.6, 1.7, and 1.8.
Tested on Python 2.6, 2.7, and 3.4, with Django 1.6, 1.7, and 1.8.

## Motivation

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def parse_markdown_readme():
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
Expand Down
6 changes: 3 additions & 3 deletions swapper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ def get_model_names(app_label, models):
"""
Map model names to their swapped equivalents for the given app
"""
return {
model: get_model_name(app_label, model)
return dict(
(model, get_model_name(app_label, model))
for model in models
}
)


def load_model(app_label, model, orm=None, required=True):
Expand Down
19 changes: 12 additions & 7 deletions tests/test_swapper.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
from django.test import TestCase
import unittest
import sys

if sys.version_info < (2, 7):
import unittest2 as unittest
else:
import unittest
import swapper
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
Expand All @@ -17,10 +22,10 @@ class SwapperTestCase(TestCase):
# Tests that should work whether or not default_app.Type is swapped
def test_fields(self):
Type = swapper.load_model('default_app', 'Type')
fields = {
field.name: field
fields = dict(
(field.name, field)
for field in Type._meta.fields
}
)
self.assertIn('name', fields)

def test_create(self):
Expand Down Expand Up @@ -55,10 +60,10 @@ def test_swap_setting(self):
@unittest.skipUnless(settings.SWAP, "requires swapped models")
def test_swap_fields(self):
Type = swapper.load_model('default_app', 'Type')
fields = {
field.name: field
fields = dict(
(field.name, field)
for field in Type._meta.fields
}
)
self.assertIn('code', fields)

@unittest.skipUnless(settings.SWAP, "requires swapped models")
Expand Down
5 changes: 4 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
[tox]
envlist =
py26-django16-unittest2-{noswap,swap},
py{27,33}-django16-{noswap,swap},
py{27,33,34}-django{17,18}-{noswap,swap}

[tox:travis]
2.6 = py26-django16-unittest2-{noswap,swap}
2.7 = py27-django{16,17,18}-{noswap,swap}
3.3 = py33-django{17,18}-{noswap,swap}
3.4 = py34-django{17,18}-{noswap,swap}

[testenv]
commands = python setup.py test
deps =
django16: django>=1.6
django16: django~=1.6.0
django17: django>=1.7
django18: django>=1.8
unittest2: unittest2
setenv =
noswap: DJANGO_SETTINGS_MODULE=tests.settings
swap: DJANGO_SETTINGS_MODULE=tests.swap_settings