Skip to content

Commit

Permalink
Merge pull request #64 from ixc/ixc/supported-versions
Browse files Browse the repository at this point in the history
Reinstate tests for supported Django & Python versions, and fix tests…
  • Loading branch information
paulocheque committed Jun 2, 2015
2 parents 81e3975 + 03657cb commit 3cffded
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 36 deletions.
36 changes: 25 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,31 @@ script:
- tox

env:
- TOXENV=py27-django14
- TOXENV=py27-django15
- TOXENV=py27-django16
- TOXENV=py27-django17
- TOXENV=py27-django18
- TOXENV=py33-django17
- TOXENV=py33-django18
- TOXENV=py34-django17
- TOXENV=py34-django18
- TOXENV=pypy-django17
- TOXENV=pypy-django18
- TOXENV=django14-py26
- TOXENV=django14-py27
- TOXENV=django14-pypy
- TOXENV=django15-py26
- TOXENV=django15-py27
- TOXENV=django15-py32
- TOXENV=django15-py33
- TOXENV=django15-py34
- TOXENV=django15-pypy
- TOXENV=django16-py26
- TOXENV=django16-py27
- TOXENV=django16-py32
- TOXENV=django16-py33
- TOXENV=django16-py34
- TOXENV=django16-pypy
- TOXENV=django17-py27
- TOXENV=django17-py32
- TOXENV=django17-py33
- TOXENV=django17-py34
- TOXENV=django17-pypy
- TOXENV=django18-py27
- TOXENV=django18-py32
- TOXENV=django18-py33
- TOXENV=django18-py34
- TOXENV=django18-pypy

after_success:
- coveralls
6 changes: 3 additions & 3 deletions django_dynamic_fixture/ddf.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def __init__(self, expression):
self.expression = expression

def __str__(self):
return u"C('%s')" % self.expression
return "C('%s')" % self.expression

def immediate_field_name(self, instance):
model_class = instance.__class__
Expand Down Expand Up @@ -248,7 +248,7 @@ def __init__(self, data_fixture, fill_nullable_fields=True, ignore_fields=[], nu
self.fields_to_disable_auto_now_add = []

def __str__(self):
return u'F(%s)' % (u', '.join(u'%s=%s' % (key, value) for key, value in self.kwargs.items()))
return 'F(%s)' % (', '.join(six.text_type('%s=%s') % (key, value) for key, value in self.kwargs.items()))

def __eq__(self, that):
return self.kwargs == that.kwargs
Expand Down Expand Up @@ -462,7 +462,7 @@ def new(self, model_class, shelve=False, named_shelve=None, persist_dependencies
self.set_data_for_a_field(model_class, instance, field, persist_dependencies=persist_dependencies, **configuration)
i += 1
if i > 2 * number_of_pending_fields: # dealing with infinite loop too.
raise InvalidConfigurationError(get_unique_field_name(field), u'Cyclic dependency of Copiers.')
raise InvalidConfigurationError(get_unique_field_name(field), 'Cyclic dependency of Copiers.')
if self.debug_mode:
LOGGER.debug('<<< [%s] Instance created.' % get_unique_model_name(model_class))
return instance
Expand Down
10 changes: 5 additions & 5 deletions django_dynamic_fixture/fixture_algorithms/random_fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

class RandomDataFixture(BaseDataFixture, GeoDjangoDataFixture):
def random_string(self, n):
return u''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(n))
return six.text_type('').join(random.choice(string.ascii_uppercase + string.digits) for _ in range(n))

# NUMBERS
def integerfield_config(self, field, key, start=1, end=10 ** 6):
Expand Down Expand Up @@ -87,20 +87,20 @@ def datetimefield_config(self, field, key):

# FORMATTED STRINGS
def emailfield_config(self, field, key):
return u'a%s@dynamicfixture.com' % self.random_string(10)
return six.text_type('a%s@dynamicfixture.com') % self.random_string(10)

def urlfield_config(self, field, key):
return u'http://dynamicfixture%s.com' % self.random_string(10)
return six.text_type('http://dynamicfixture%s.com') % self.random_string(10)

def ipaddressfield_config(self, field, key):
a = random.randint(1, 255)
b = random.randint(1, 255)
c = random.randint(1, 255)
d = random.randint(1, 255)
return u'%s.%s.%s.%s' % (a, b, c, d)
return six.text_type('%s.%s.%s.%s') % (a, b, c, d)

def xmlfield_config(self, field, key):
return u'<a>%s</a>' % self.random_string(5)
return six.text_type('<a>%s</a>') % self.random_string(5)

# FILES
def filepathfield_config(self, field, key):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ def datetimefield_config(self, field, key):

# FORMATTED STRINGS
def emailfield_config(self, field, key):
return u'a%s@dynamicfixture.com' % self.get_value(field, key)
return six.text_type('a%s@dynamicfixture.com') % self.get_value(field, key)

def urlfield_config(self, field, key):
return u'http://dynamicfixture%s.com' % self.get_value(field, key)
return six.text_type('http://dynamicfixture%s.com') % self.get_value(field, key)

def ipaddressfield_config(self, field, key):
# TODO: better workaround (this suppose ip field is not unique)
Expand All @@ -132,10 +132,10 @@ def ipaddressfield_config(self, field, key):
b = '1'
c = '1'
d = data % 256
return u'%s.%s.%s.%s' % (a, b, c, str(d))
return six.text_type('%s.%s.%s.%s') % (a, b, c, str(d))

def xmlfield_config(self, field, key):
return u'<a>%s</a>' % self.get_value(field, key)
return six.text_type('<a>%s</a>') % self.get_value(field, key)

# FILES
def filepathfield_config(self, field, key):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def random_string(self, field, key, n=None):
counter = six.text_type(self.get_counter(field, key))
length = n or self.DEFAULT_LENGTH
result = counter
result += u''.join(
result += six.text_type('').join(
random.choice(string.ascii_letters)
for _ in xrange(length - len(counter))
)
Expand Down Expand Up @@ -144,10 +144,10 @@ def datetimefield_config(self, field, key):

# FORMATTED STRINGS
def emailfield_config(self, field, key):
return u'a%s@dynamicfixture.com' % self.random_string(field, key)
return six.text_type('a%s@dynamicfixture.com') % self.random_string(field, key)

def urlfield_config(self, field, key):
return u'http://dynamicfixture%s.com' % self.random_string(field, key)
return six.text_type('http://dynamicfixture%s.com') % self.random_string(field, key)

def ipaddressfield_config(self, field, key):
MAX_IP = 2 ** 32 - 1
Expand All @@ -157,7 +157,7 @@ def ipaddressfield_config(self, field, key):
return six.text_type(socket.inet_ntoa(struct.pack('!L', integer)))

def xmlfield_config(self, field, key):
return u'<a>%s</a>' % self.random_string(field, key)
return six.text_type('<a>%s</a>') % self.random_string(field, key)

# FILES
def filepathfield_config(self, field, key):
Expand Down
6 changes: 2 additions & 4 deletions django_dynamic_fixture/tests/test_ddf.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,10 +818,8 @@ def test_BadDataError(self):
template1 = "('%s', IntegrityError('%s',))" % (model_msg, error_msg)
template2 = "('%s', IntegrityError('%s',))" % (model_msg, error_msg2) # py34
template3 = "('%s', IntegrityError(u'%s',))" % (model_msg, error_msg) # pypy
try:
self.assertEquals(str(e) in [template1, template2, template3], True, msg=str(e))
except AssertionError:
pass # It is ok to have a different template
template4 = "('%s', IntegrityError(u'%s',))" % (model_msg, error_msg2) # pypy
self.assertEquals(str(e) in [template1, template2, template3, template4], True, msg=str(e))


def test_InvalidConfigurationError(self):
Expand Down
10 changes: 5 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
[tox]
envlist =
django14-py{27},
django15-py{27},
django16-py{27,33},
django17-py{27,33,34,py},
django18-py{27,33,34,py},
django14-py{26,27,py},
django{15,16}-py{26,27,32,33,34,py},
django{17,18}-py{27,32,33,34,py},

[testenv]
setenv =
Expand All @@ -16,7 +14,9 @@ setenv =
NOSE_OPENSTACK_SHOW_ELAPSED=1

basepython=
py26: python2.6
py27: python2.7
py32: python3.2
py33: python3.3
py34: python3.4
pypy: pypy
Expand Down

0 comments on commit 3cffded

Please sign in to comment.