summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Plant <L.Plant.98@cantab.net>2011-01-08 16:13:58 +0000
committerLuke Plant <L.Plant.98@cantab.net>2011-01-08 16:13:58 +0000
commit03ab30c3f10b5cf20698ae9ac7b56caa47a88552 (patch)
tree2df5578d040531378fa76d4db55c181a03108806
parent989486d05daae847e5b121d6bef5bb53b16cfe98 (diff)
[1.2.X] Fixed test failure when using Python 2.7
Backport of [14309] from trunk. Fixed #14947 git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@15165 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--tests/regressiontests/fixtures_regress/tests.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/regressiontests/fixtures_regress/tests.py b/tests/regressiontests/fixtures_regress/tests.py
index 57ee7c0451..9655ba00ce 100644
--- a/tests/regressiontests/fixtures_regress/tests.py
+++ b/tests/regressiontests/fixtures_regress/tests.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
# Unittests for fixtures.
import os
+import re
import sys
try:
from cStringIO import StringIO
@@ -327,9 +328,14 @@ class TestFixtures(TestCase):
# Output order isn't guaranteed, so check for parts
data = stdout.getvalue()
+
+ # Get rid of artifacts like '000000002' to eliminate the differences
+ # between different Python versions.
+ data = re.sub('0{6,}\d', '', data)
+
lion_json = '{"pk": 1, "model": "fixtures_regress.animal", "fields": {"count": 3, "weight": 1.2, "name": "Lion", "latin_name": "Panthera leo"}}'
emu_json = '{"pk": 10, "model": "fixtures_regress.animal", "fields": {"count": 42, "weight": 1.2, "name": "Emu", "latin_name": "Dromaius novaehollandiae"}}'
- platypus_json = '{"pk": %d, "model": "fixtures_regress.animal", "fields": {"count": 2, "weight": 2.2000000000000002, "name": "Platypus", "latin_name": "Ornithorhynchus anatinus"}}'
+ platypus_json = '{"pk": %d, "model": "fixtures_regress.animal", "fields": {"count": 2, "weight": 2.2, "name": "Platypus", "latin_name": "Ornithorhynchus anatinus"}}'
platypus_json = platypus_json % animal.pk
self.assertEqual(len(data), len('[%s]' % ', '.join([lion_json, emu_json, platypus_json])))